home *** CD-ROM | disk | FTP | other *** search
/ Programming Languages Suite / ProgramD2.iso / Borland / Borland C++ V5.02 / OWLPORTH.PAK / OWLHDR.H < prev    next >
C/C++ Source or Header  |  1997-05-06  |  95KB  |  2,821 lines

  1. // OWLCVT
  2. // ObjectWindows - (C) Copyright 1992 by Borland International
  3.  
  4. #if !defined(__OWLHDR_H)
  5. #define __OWLHDR_H
  6.  
  7. #if defined(_CLASSDLL) || defined(__DLL__)
  8. #  define _RTLDLL
  9. #endif
  10.  
  11. #if !defined(BI_OLDNAMES)
  12. #define BI_OLDNAMES
  13. #endif
  14.  
  15. #include <_defs.h>
  16. #include <typeinfo.h>
  17. #include <fstream.h>
  18. #include <iostream.h>
  19. #include <stdiostr.h>
  20. #include <strstrea.h>
  21. #include <cstring.h>
  22.  
  23. //
  24. // RTTI and DDVTs don't get along, so we need to disable RTTI
  25. // for OWL 1 code. This also means that we must disable exceptions.
  26. //
  27. #pragma option -RT-
  28. #pragma option -x-
  29.  
  30. #include <owlrc.h>
  31. #include <stddef.h>
  32. #include <object.h>
  33. #include <windows.h>
  34. #include <dir.h>
  35. #include <array.h>
  36. #include <strng.h>
  37. #include <stdlib.h>
  38. #include <dos.h>
  39.  
  40. #if         defined(BUILD_OWL)
  41.  
  42. #if         !defined(WIN31) || !defined(STRICT)
  43. #error   OWL must be built with WIN31 and STRICT defined.
  44. #endif
  45.  
  46. #if         defined(__COMPACT__)
  47. #error   OWL cannot be built in Compact model.
  48. #endif
  49.  
  50. #if         defined(__TINY__)
  51. #error   OWL cannot be built in Tiny model.
  52. #endif
  53.  
  54. #else   //  !defined(BUILD_OWL)
  55.  
  56. #if         !defined(WIN31) || !defined(STRICT)
  57. #error   OWL applications must be built with WIN31 and STRICT defined.
  58. #endif
  59.  
  60. #if         defined(__COMPACT__)
  61. #error   OWL applications cannot be built in Compact model.
  62. #endif
  63.  
  64. #if         defined(__TINY__)
  65. #error   OWL applications cannot be built in Tiny model.
  66. #endif
  67.  
  68. #endif  //  !defined(BUILD_OWL)
  69.  
  70. #if defined(__cplusplus)
  71. typedef int       _FAR &        Rint;
  72. typedef int       _FAR *        Pint;
  73. typedef void       _FAR *        Pvoid;
  74. typedef void       _FAR * _FAR &    RPvoid;
  75. typedef char       _FAR *        Pchar;
  76. typedef const char _FAR *        PCchar;
  77. typedef const void _FAR *        PCvoid;
  78.  
  79. // windows 3.0-compatibility types
  80.  
  81. #if  defined(WIN30)
  82.  
  83. #define            _WIN30_API           1
  84.  
  85. typedef long                            LONG_30;
  86. typedef unsigned int                    WORD_30;
  87. typedef unsigned int                    WORD_30;
  88. typedef unsigned int                    HDC_30;
  89. typedef unsigned int                    HWND_30;
  90. typedef unsigned int                    HINSTANCE_30;
  91.  
  92. #endif
  93. #endif
  94.  
  95. /* Since some resource editors strip comments from header files, some
  96.    brief comments on the contents of owlrc.h are included here:
  97.  
  98.    The SD_ constants are used for the File Open, File Save, Input,
  99.    Search and Replace dialogs.
  100.  
  101.    ID_FNAME, ID_FPATH, ID_FLIST and ID_DLIST are used for TFileDialog.
  102.  
  103.    ID_PROMPT, ID_INPUT, ID_SEARCHTEXT, ID_CASESENSITIVE, ID_REPLACETEXT,
  104.    ID_REPLACEALL and ID_PROMPTONREPLACE are used by TSearchDialog.
  105.  
  106.    ID_EDITOR is used by TEditWindow.
  107.  
  108.    ID_MDICLIENT is the default id for TMDIClient and ID_FIRSTMDICHILD
  109.    is the id of the first MDI child created by a TMDIClient.
  110.  
  111.    Note that the ID_ constants defined in OWL are all greater than or
  112.    equal to ID_RESERVED. Any ID_ constants you use should be less than
  113.    ID_RESERVED.
  114.  
  115.    Note that the CM_ constants defined in OWL are all greater than or
  116.    equal to CM_RESERVED. Any CM_ constants you use should be less than
  117.    CM_RESERVED.
  118.  
  119. */
  120.  
  121. /* Constants for application messages */
  122. #define WM_FIRST        0x0000  /* 0x0000- 0x7FFF window messages */
  123. #define WM_INTERNAL     0x7F00  /* 0x7F00- 0x7FFF reserved for internal use */
  124. #define ID_FIRST        0x8000  /* 0x8000- 0x8FFF child id messages */
  125. #define ID_INTERNAL     0x8F00  /* 0x8F00- 0x8FFF reserved for internal use */
  126. #define NF_FIRST        0x9000  /* 0x9000- 0x9FFF notification messages */
  127. #define NF_INTERNAL     0x9F00  /* 0x9F00- 0x9FFF reserved for internal use */
  128. #define CM_FIRST        0xA000  /* 0xA000- 0xFFFF command messages */
  129. #define CM_INTERNAL     0xFF00  /* 0xFF00- 0xFFFF reserved for internal use */
  130. #define WM_COUNT     0x8000    /* num of window msgs */
  131. #define ID_COUNT     0x1000    /* num of child id msgs */
  132. #define NF_COUNT     0x1000    /* num of notification msgs */
  133. #define CM_COUNT     0x6000    /* num of command msgs */
  134.  
  135. #define WM_RESERVED             WM_INTERNAL - WM_FIRST
  136.  
  137. #define ID_RESERVED             ID_INTERNAL - ID_FIRST
  138. #define ID_FIRSTMDICHILD        ID_RESERVED + 1
  139. #define ID_MDICLIENT             ID_RESERVED + 2
  140.  
  141. #define CM_RESERVED             CM_INTERNAL - CM_FIRST
  142.  
  143.  
  144.   /* Bit masks for TWindowsObject Flags */
  145. #define WB_ALIAS              0x01
  146. #define WB_AUTOCREATE         0x02
  147. #define WB_FROMRESOURCE       0x04
  148. #define WB_KBHANDLER          0x08
  149. #define WB_MDICHILD           0x10
  150. #define WB_MDIFRAME           0x20
  151. #define WB_PREDEFINEDCLASS    0x40
  152. #define WB_TRANSFER           0x80
  153.  
  154.   /* Error conditions */
  155. #define EM_INVALIDCHILD         -1
  156. #define EM_INVALIDCLIENT        -2
  157. #define EM_INVALIDMAINWINDOW    -3
  158. #define EM_INVALIDMODULE        -4
  159. #define EM_INVALIDWINDOW        -5
  160. #define EM_OUTOFMEMORY          -6
  161.  
  162.   /* Transfer function flags */
  163. #define TF_GETDATA               0
  164. #define TF_SETDATA               1
  165. #define TF_SIZEDATA              2
  166.  
  167. /* Checkbox flags indicating check state */
  168. #define BF_CHECKED      0x1
  169. #define BF_GRAYED       0x2
  170. #define BF_UNCHECKED    0x0
  171.  
  172. // define classes types for isA()
  173.  
  174. #define  moduleClass          (__firstOWLClass)
  175. #define  applicationClass     (moduleClass + 1)
  176. #define  scrollerClass        (applicationClass + 1)
  177. #define  windowClass          (scrollerClass + 1)
  178. #define  dialogClass          (windowClass + 1)
  179.  
  180. #if  defined(__DLL__)
  181. #  define _EXPORT _export
  182. #else
  183. #  define _EXPORT _CLASSTYPE
  184. #endif
  185.  
  186. const int DEFAULT_SAFETY_POOL_SIZE = 8192;
  187.  
  188. _CLASSDEF(SafetyPool)
  189.  
  190. class _EXPORT SafetyPool
  191. {
  192. public:
  193.     static  int            Allocate(size_t size
  194.                     = DEFAULT_SAFETY_POOL_SIZE);
  195.     static  int            IsExhausted()
  196.                   // returns true if safetyPool is exhausted
  197.                   { return safetyPool == NULL; };
  198.     static  int            Size;
  199.     static  Pvoid         safetyPool;
  200. };
  201.  
  202. enum Boolean { False, True };
  203.  
  204. typedef unsigned short ushort;
  205. typedef unsigned char uchar;
  206.  
  207. const char EOS = '\0';
  208.  
  209. typedef int ccIndex;
  210. typedef Boolean (_FAR *ccTestFunc)( Pvoid, Pvoid );
  211. typedef void (_FAR *ccAppFunc)( Pvoid, Pvoid );
  212.  
  213. const ccNotFound = -1;
  214. const maxCollectionSize = (int)((65536uL - 16)/sizeof( Pvoid ));
  215.  
  216. const TCOLLECTION_CLASS_HASH_VALUE = 0;
  217.  
  218. _CLASSDEF(TNSCollection)
  219. _CLASSDEF(TNSSortedCollection)
  220.  
  221. class _CLASSTYPE TNSCollection
  222. {
  223. public:
  224.  
  225.     TNSCollection( ccIndex aLimit, ccIndex aDelta );
  226.     ~TNSCollection();
  227.  
  228.     Pvoid at( ccIndex index );
  229.     virtual ccIndex indexOf( Pvoid item );
  230.  
  231.     void atFree( ccIndex index );
  232.     void atRemove( ccIndex index );
  233.     void remove( Pvoid item );
  234.     void removeAll();
  235.     void free( Pvoid item );
  236.     void freeAll();
  237.  
  238.     void atInsert( ccIndex index, Pvoid item );
  239.     void atPut( ccIndex index, Pvoid item );
  240.     virtual ccIndex insert( Pvoid item );
  241.  
  242.     static void error( ccIndex code, ccIndex info );
  243.  
  244.     Pvoid firstThat( ccTestFunc Test, Pvoid arg );
  245.     Pvoid lastThat( ccTestFunc Test, Pvoid arg );
  246.     void forEach( ccAppFunc action, Pvoid arg );
  247.  
  248.     void pack();
  249.     virtual void setLimit( ccIndex aLimit );
  250.  
  251.     ccIndex getCount()
  252.         { return count; }
  253.  
  254. protected:
  255.  
  256.     TNSCollection();
  257.  
  258.     Pvoid _FAR *items;
  259.     ccIndex count;
  260.     ccIndex limit;
  261.     ccIndex delta;
  262.     Boolean shouldDelete;
  263.  
  264. private:
  265.  
  266.     virtual void freeItem( Pvoid item );
  267. };
  268.  
  269. class _CLASSTYPE TNSSortedCollection: public virtual TNSCollection
  270. {
  271. public:
  272.  
  273.     TNSSortedCollection( ccIndex aLimit, ccIndex aDelta) :
  274.         TNSCollection( aLimit, aDelta )
  275.         { delta = aDelta; setLimit( aLimit ); }
  276.  
  277.     virtual Boolean search( Pvoid key, ccIndex _FAR & index );
  278.  
  279.     virtual ccIndex indexOf( Pvoid item );
  280.     virtual ccIndex insert( Pvoid item );
  281.  
  282.     Boolean duplicates;
  283.  
  284. protected:
  285.  
  286.     TNSSortedCollection() {};
  287.     virtual Pvoid keyOf( Pvoid item ) { return item; }
  288.  
  289. private:
  290.  
  291.     virtual int compare( Pvoid key1, Pvoid key2 ) = 0;
  292. };
  293.  
  294. #if !defined( __fLink_def )
  295. #define __fLink_def
  296. struct fLink
  297. {
  298.     fLink near *f;
  299.     class _CLASSTYPE TStreamableClass near *t;
  300. };
  301. #endif
  302.  
  303. #define __link( s )             \
  304.   extern TStreamableClass s;    \
  305.   static fLink force ## s =     \
  306.     { (fLink near *)&force ## s, (TStreamableClass near *)&s };
  307.  
  308. typedef unsigned P_id_type;
  309.  
  310. enum StreamableInit { streamableInit };
  311.  
  312. /* ------------------------------------------------------------------------*/
  313. /*                                                                         */
  314. /*   class TStreamable                                                     */
  315. /*                                                                         */
  316. /*   This is the base class for all storable objects.  It provides         */
  317. /*   three member functions, streamableName(), read(), and write(), which  */
  318. /*   must be overridden in every derived class.                            */
  319. /*                                                                         */
  320. /* ------------------------------------------------------------------------*/
  321.  
  322. _CLASSDEF(TStreamable)
  323. _CLASSDEF(TStreamableClass)
  324. _CLASSDEF(TStreamableTypes)
  325. _CLASSDEF(TPWrittenObjects)
  326. _CLASSDEF(TPWObj)
  327. _CLASSDEF(TPReadObjects)
  328. _CLASSDEF(pstream)
  329. _CLASSDEF(ipstream)
  330. _CLASSDEF(opstream)
  331. _CLASSDEF(iopstream)
  332. _CLASSDEF(fpbase)
  333. _CLASSDEF(ifpstream)
  334. _CLASSDEF(ofpstream)
  335. _CLASSDEF(fpstream)
  336.  
  337. class _CLASSTYPE TStreamable
  338. {
  339.  
  340.     friend class _CLASSTYPE opstream;
  341.     friend class _CLASSTYPE ipstream;
  342.  
  343. private:
  344.  
  345.     virtual const Pchar streamableName() const = 0;
  346.  
  347. protected:
  348.  
  349.     virtual Pvoid read(Ripstream) = 0;
  350.     virtual void write(Ropstream) = 0;
  351. };
  352.  
  353. /* ------------------------------------------------------------------------*/
  354. /*                                                                         */
  355. /*   class TStreamableClass                                                */
  356. /*                                                                         */
  357. /*   Used internally by TStreamableTypes and pstream.                      */
  358. /*                                                                         */
  359. /* ------------------------------------------------------------------------*/
  360.  
  361. typedef PTStreamable (_FAR *BUILDER)();
  362. #define __DELTA( d ) (FP_OFF((TStreamable *)(d *)1)-1)
  363.  
  364. class _CLASSTYPE TStreamableClass
  365. {
  366.     friend class _CLASSTYPE TStreamableTypes;
  367.     friend class _CLASSTYPE opstream;
  368.     friend class _CLASSTYPE ipstream;
  369.     friend class _CLASSTYPE TObjStrmRegRecord;
  370.  
  371. public:
  372.  
  373.     TStreamableClass( PCchar n, BUILDER b, int d );
  374.  
  375. protected:
  376.     PCchar name;
  377.     BUILDER build;
  378.     int delta;
  379. };
  380.  
  381. class _CLASSTYPE TObjStrmRegRecord
  382. {
  383.     friend class TStreamableClass;
  384. public:
  385.     TObjStrmRegRecord(PTStreamableClass pTStreamableClass);
  386.     int Validate();
  387.  
  388.     PTStreamableClass pTStreamableClass;
  389. private:
  390.     unsigned short SegmentLimit;
  391.     unsigned short Checksum;
  392.     Pvoid operator new (size_t s);
  393.     void operator delete(Pvoid ptr);
  394. };
  395.  
  396. /* ------------------------------------------------------------------------*/
  397. /*                                                                         */
  398. /*   class TStreamableTypes                                                */
  399. /*                                                                         */
  400. /*   Maintains a database of all registered types in the application.      */
  401. /*   Used by opstream and ipstream to find the functions to read and       */
  402. /*   write objects.                                                        */
  403. /*                                                                         */
  404. /* ------------------------------------------------------------------------*/
  405.  
  406. class _CLASSTYPE TStreamableTypes : private TNSSortedCollection
  407. {
  408.  
  409. public:
  410.  
  411.     TStreamableTypes() : TNSSortedCollection( 5, 5 )
  412.         {duplicates = True;}
  413.     ~TStreamableTypes() { shouldDelete = False; }
  414.  
  415. #if !defined(__DLL__)
  416.     void registerType( PCTStreamableClass d)
  417.         { insert( (void *)d ); }
  418. #else
  419.     void registerType(TObjStrmRegRecord *pTObjStrmRegRecord);
  420. #endif
  421.  
  422.     PCTStreamableClass lookup( PCchar );
  423.  
  424.     Pvoid operator new( size_t sz ) { return ::operator new( sz ); }
  425.     Pvoid operator new( size_t, Pvoid arena ) { return arena; }
  426.  
  427. protected:
  428.     virtual Boolean search( Pvoid key, ccIndex _FAR & index );
  429.  
  430. private:
  431.     virtual Pvoid keyOf(Pvoid d);
  432.     int compare( Pvoid, Pvoid );
  433. };
  434.  
  435.  
  436. /* ------------------------------------------------------------------------*/
  437. /*                                                                         */
  438. /*   class TPWObj                                                          */
  439. /*                                                                         */
  440. /*   Used internally by TPWrittenObjects.                                  */
  441. /*                                                                         */
  442. /* ------------------------------------------------------------------------*/
  443.  
  444. class _CLASSTYPE TPWObj
  445. {
  446.     
  447.     friend class _CLASSTYPE TPWrittenObjects;
  448.     friend class _CLASSTYPE TPReadObjects;
  449.     friend class _CLASSTYPE ipstream;
  450.     friend class _CLASSTYPE opstream;
  451.  
  452. private:
  453.  
  454.     TPWObj(PCvoid adr, P_id_type id ) : address( Pvoid(adr) ), ident( id ) {}
  455.  
  456.     Pvoid address;
  457.     P_id_type ident;
  458.  
  459. };
  460.  
  461. /* ------------------------------------------------------------------------*/
  462. /*                                                                         */
  463. /*   class TPWrittenObjects                                                */
  464. /*                                                                         */
  465. /*   Maintains a database of all objects that have been written to the     */
  466. /*   current object stream.                                                */
  467. /*                                                                         */
  468. /*   Used by opstream when it writes a pointer onto a stream to determine  */
  469. /*   whether the object pointed to has already been written to the stream. */
  470. /*                                                                         */
  471. /* ------------------------------------------------------------------------*/
  472.  
  473. class _CLASSTYPE TPWrittenObjects : public TNSSortedCollection
  474. {
  475.  
  476.     friend class _CLASSTYPE opstream;
  477.  
  478. public:
  479.  
  480.     void removeAll() { curId = 1; TNSSortedCollection::removeAll(); }
  481.  
  482. private:
  483.  
  484.     TPWrittenObjects() : TNSSortedCollection( 5, 5 ), curId( 1 ) {}
  485.     ~TPWrittenObjects() { shouldDelete = False; }
  486.  
  487.     void registerObject( PCvoid adr );
  488.     P_id_type find( PCvoid adr );
  489.  
  490.     Pvoid keyOf(Pvoid d) { return ((TPWObj *)d)->address; }
  491.     int compare( Pvoid, Pvoid );
  492.  
  493.     P_id_type curId;
  494.  
  495. };
  496.  
  497. /* ------------------------------------------------------------------------*/
  498. /*                                                                         */
  499. /*   class TPReadObjects                                                   */
  500. /*                                                                         */
  501. /*   Maintains a database of all objects that have been read from the      */
  502. /*   current persistent stream.                                            */
  503. /*                                                                         */
  504. /*   Used by ipstream when it reads a pointer from a stream to determine   */
  505. /*   the address of the object being referred to.                          */
  506. /*                                                                         */
  507. /* ------------------------------------------------------------------------*/
  508.  
  509. class _CLASSTYPE TPReadObjects : public TNSCollection
  510. {
  511.  
  512.     friend class _CLASSTYPE ipstream;
  513.  
  514. public:
  515.  
  516.     void removeAll() { curId = 1; TNSCollection::removeAll(); }
  517.  
  518. private:
  519.  
  520.     TPReadObjects() : TNSCollection( 5, 5 ), curId( 1 )
  521.         { insert( 0 ); }    // prime it, so we won't use index 0
  522.     ~TPReadObjects() { shouldDelete = False; }
  523.  
  524.     void registerObject( PCvoid adr );
  525.     PCvoid find( P_id_type id ) { return at( id ); }
  526.     P_id_type curId;
  527.  
  528. };
  529.  
  530. /* ------------------------------------------------------------------------*/
  531. /*                                                                         */
  532. /*   class pstream                                                         */
  533. /*                                                                         */
  534. /*   Base class for handling streamable objects.                           */
  535. /*                                                                         */
  536. /* ------------------------------------------------------------------------*/
  537.  
  538. class _CLASSTYPE pstream
  539. {
  540.  
  541.     friend class _CLASSTYPE TStreamableTypes;
  542.  
  543. public:
  544.  
  545.     enum StreamableError { peNotRegistered = 0x1000, peInvalidType = 0x2000 };
  546.     enum PointerTypes { ptNull, ptIndexed, ptObject };
  547.  
  548.     _Cdecl pstream( Pstreambuf sb ) { init( sb ); }
  549.     virtual _Cdecl ~pstream() {}
  550.  
  551.     int _Cdecl rdstate() const { return state; }
  552.     int _Cdecl eof() const { return state & ios::eofbit; }
  553.     int _Cdecl fail() const
  554.         { return state & (ios::failbit | ios::badbit | ios::hardfail); }
  555.     int _Cdecl bad() const { return state & (ios::badbit | ios::hardfail); }
  556.     int _Cdecl good() const { return state == 0; }
  557.  
  558.     void _Cdecl clear( int i = 0 )
  559.         { state = (i & 0xFF) | (state & ios::hardfail); }
  560.  
  561.     _Cdecl operator Pvoid() const { return fail() ? 0 : (void *)this; }
  562.     int _Cdecl operator ! () const { return fail(); }
  563.  
  564.     Pstreambuf _Cdecl rdbuf() const { return bp; }
  565.  
  566.     static void initTypes();
  567.     static PTStreamableTypes types;
  568.  
  569. protected:
  570.  
  571.     _Cdecl pstream() {}
  572.  
  573.     void _Cdecl error( StreamableError );
  574.     void _Cdecl error( StreamableError, RCTStreamable );
  575.  
  576.     Pstreambuf bp;
  577.     int state;
  578.     
  579.     void _Cdecl init( Pstreambuf sbp) { state = 0; bp = sbp; }
  580.     void _Cdecl setstate( int b) { state |= (b&0x00FF); }
  581. };
  582.  
  583. /* ------------------------------------------------------------------------*/
  584. /*                                                                         */
  585. /*   class ipstream                                                        */
  586. /*                                                                         */
  587. /*   Base class for reading streamable objects                             */
  588. /*                                                                         */
  589. /* ------------------------------------------------------------------------*/
  590.  
  591. class _CLASSTYPE ipstream : virtual public pstream
  592. {
  593.  
  594. public:
  595.  
  596.     _Cdecl  ipstream( Pstreambuf sb) { pstream::init( sb ); }
  597.     _Cdecl ~ipstream() {}
  598.  
  599.     streampos _Cdecl tellg()
  600.         { return bp->seekoff( 0, ios::cur, ios::in ); }
  601.  
  602.     Ripstream _Cdecl seekg( streampos );
  603.     Ripstream _Cdecl seekg( streamoff, ios::seek_dir );
  604.  
  605.     uchar _Cdecl readByte() { return bp->sbumpc(); }
  606.     void _Cdecl readBytes( Pvoid data, size_t sz)
  607.         { bp->sgetn( (char *)data, sz ); }
  608.     void _Cdecl freadBytes( void far *data, size_t sz );
  609.  
  610.     ushort _Cdecl readWord();
  611.     Pchar _Cdecl readString();
  612.     Pchar _Cdecl readString( Pchar, unsigned );
  613.     char far *freadString();
  614.     char far *freadString( char far *buf, unsigned maxLen );
  615.  
  616.     friend Ripstream _Cdecl _EXPFUNC operator >> ( Ripstream,
  617.         signed char _FAR & );
  618.     friend Ripstream _Cdecl _EXPFUNC operator >> ( Ripstream,
  619.         unsigned char _FAR & );
  620.     friend Ripstream _Cdecl _EXPFUNC operator >> ( Ripstream,
  621.         signed short _FAR & );
  622.     friend Ripstream _Cdecl _EXPFUNC operator >> ( Ripstream,
  623.         unsigned short _FAR & );
  624.     friend Ripstream _Cdecl _EXPFUNC operator >> ( Ripstream,
  625.         signed int _FAR & );
  626.     friend Ripstream _Cdecl _EXPFUNC operator >> ( Ripstream,
  627.         unsigned int _FAR & );
  628.     friend Ripstream _Cdecl _EXPFUNC operator >> ( Ripstream,
  629.         signed long _FAR & );
  630.     friend Ripstream _Cdecl _EXPFUNC operator >> ( Ripstream,
  631.         unsigned long _FAR & );
  632.     friend Ripstream _Cdecl _EXPFUNC operator >> ( Ripstream,
  633.         float _FAR & );
  634.     friend Ripstream _Cdecl _EXPFUNC operator >> ( Ripstream,
  635.         double _FAR & );
  636.     friend Ripstream _Cdecl _EXPFUNC operator >> ( Ripstream,
  637.         long double _FAR & );
  638.  
  639.     friend Ripstream _Cdecl _EXPFUNC operator >> ( Ripstream, RTStreamable );
  640.     friend Ripstream _Cdecl _EXPFUNC operator >> ( Ripstream, RPvoid);
  641.  
  642. protected:
  643.  
  644.     _Cdecl ipstream() {}
  645.  
  646.     PCTStreamableClass _Cdecl readPrefix();
  647.     Pvoid _Cdecl readData( PCTStreamableClass, PTStreamable );
  648.     void _Cdecl readSuffix();
  649.  
  650.     PCvoid _Cdecl find( P_id_type id) { return objs.find( id ); }
  651.     void _Cdecl registerObject( PCvoid adr ) { objs.registerObject( adr ); }
  652.  
  653. private:
  654.  
  655.     TPReadObjects objs;
  656.  
  657. };
  658.  
  659. /* ------------------------------------------------------------------------*/
  660. /*                                                                         */
  661. /*   class opstream                                                        */
  662. /*                                                                         */
  663. /*   Base class for writing streamable objects                             */
  664. /*                                                                         */
  665. /* ------------------------------------------------------------------------*/
  666.  
  667. class _CLASSTYPE opstream : virtual public pstream
  668. {
  669.  
  670. public:
  671.  
  672.     _Cdecl opstream( Pstreambuf sb) { pstream::init( sb ); }
  673.     _Cdecl ~opstream() {}
  674.  
  675.     streampos _Cdecl tellp() { return bp->seekoff( 0, ios::cur, ios::out ); }
  676.     Ropstream _Cdecl seekp( streampos pos);
  677.     Ropstream _Cdecl seekp( streamoff off, ios::seek_dir dir);
  678.     Ropstream _Cdecl flush();
  679.  
  680.     void _Cdecl writeByte( uchar ch) { bp->sputc( ch ); }
  681.     void _Cdecl writeBytes( PCvoid data, size_t sz)
  682.         { bp->sputn( (char *)data, sz ); }
  683.     void _Cdecl fwriteBytes( const void far *data, size_t sz );
  684.  
  685.     void _Cdecl writeWord( ushort sh)
  686.         { bp->sputn( (char *)&sh, sizeof( ushort ) ); }
  687.  
  688.     void _Cdecl writeString( PCchar );
  689.     void _Cdecl fwriteString( const char far * str );
  690.  
  691.     friend Ropstream _Cdecl _EXPFUNC operator << ( Ropstream, signed char );
  692.     friend Ropstream _Cdecl _EXPFUNC operator << ( Ropstream, unsigned char );
  693.     friend Ropstream _Cdecl _EXPFUNC operator << ( Ropstream, signed short );
  694.     friend Ropstream _Cdecl _EXPFUNC operator << ( Ropstream, unsigned short );
  695.     friend Ropstream _Cdecl _EXPFUNC operator << ( Ropstream, signed int );
  696.     friend Ropstream _Cdecl _EXPFUNC operator << ( Ropstream, unsigned int );
  697.     friend Ropstream _Cdecl _EXPFUNC operator << ( Ropstream, signed long );
  698.     friend Ropstream _Cdecl _EXPFUNC operator << ( Ropstream, unsigned long );
  699.     friend Ropstream _Cdecl _EXPFUNC operator << ( Ropstream, float );
  700.     friend Ropstream _Cdecl _EXPFUNC operator << ( Ropstream, double );
  701.     friend Ropstream _Cdecl _EXPFUNC operator << ( Ropstream, long double );
  702.  
  703.     friend Ropstream _Cdecl _EXPFUNC operator << ( Ropstream, RTStreamable );
  704.     friend Ropstream _Cdecl _EXPFUNC operator << ( Ropstream, PTStreamable );
  705.  
  706. protected:
  707.  
  708.     _Cdecl opstream() {}
  709.  
  710.     void _Cdecl writePrefix( RCTStreamable );
  711.     void _Cdecl writeData( RTStreamable );
  712.     void _Cdecl writeSuffix( RCTStreamable )
  713.         { writeByte( ']' ); }
  714.  
  715.     P_id_type _Cdecl find( PCvoid adr ) { return objs.find( adr ); }
  716.     void _Cdecl registerObject( PCvoid adr ) { objs.registerObject( adr ); }
  717.  
  718. private:
  719.     TPWrittenObjects objs;
  720.  
  721. };
  722.  
  723. /* ------------------------------------------------------------------------*/
  724. /*                                                                         */
  725. /*   class iopstream                                                       */
  726. /*                                                                         */
  727. /*   Base class for reading and writing streamable objects                 */
  728. /*                                                                         */
  729. /* ------------------------------------------------------------------------*/
  730.  
  731. class _CLASSTYPE iopstream : public ipstream, public opstream
  732. {
  733.  
  734. public:
  735.  
  736.     _Cdecl iopstream( Pstreambuf sb) { pstream::init( sb ); }
  737.     _Cdecl ~iopstream() {}
  738.  
  739. protected:
  740.  
  741.     _Cdecl iopstream() {}
  742. };
  743.  
  744. /* ------------------------------------------------------------------------*/
  745. /*                                                                         */
  746. /*   class fpbase                                                          */
  747. /*                                                                         */
  748. /*   Base class for handling streamable objects on file streams            */
  749. /*                                                                         */
  750. /* ------------------------------------------------------------------------*/
  751.  
  752. class _CLASSTYPE fpbase : virtual public pstream
  753. {
  754.     
  755. public:
  756.  
  757.     _Cdecl fpbase() { pstream::init( &buf ); }
  758.     _Cdecl fpbase( PCchar, int, int = filebuf::openprot );
  759.     _Cdecl fpbase( int f ) : buf (f) { pstream::init( &buf ); }
  760.     _Cdecl fpbase( int f, Pchar b, int len) : buf( f, b, len )
  761.         { pstream::init( &buf ); }
  762.     _Cdecl ~fpbase() {}
  763.  
  764.     void _Cdecl open( PCchar, int, int = filebuf::openprot );
  765.     void _Cdecl attach( int );
  766.     void _Cdecl close();
  767.     void _Cdecl setbuf( Pchar, int );
  768.     Pfilebuf _Cdecl rdbuf() { return &buf; }
  769.     
  770. private:
  771.  
  772.     filebuf buf;
  773.  
  774. };
  775.  
  776. /* ------------------------------------------------------------------------*/
  777. /*                                                                         */
  778. /*   class ifpstream                                                       */
  779. /*                                                                         */
  780. /*   Base class for reading streamable objects from file streams           */
  781. /*                                                                         */
  782. /* ------------------------------------------------------------------------*/
  783.  
  784. class _CLASSTYPE ifpstream : public fpbase, public ipstream
  785. {
  786.  
  787. public:
  788.  
  789.     _Cdecl ifpstream() {}
  790.     _Cdecl ifpstream( PCchar name,
  791.                       int mode = ios::in,
  792.                       int prot = filebuf::openprot
  793.                     );
  794.     _Cdecl ifpstream(int f) : fpbase( f ) {}
  795.     _Cdecl ifpstream( int f, Pchar b, int len) : fpbase(f, b, len) {}
  796.     _Cdecl ~ifpstream() {}
  797.  
  798.     Pfilebuf _Cdecl rdbuf() { return fpbase::rdbuf(); }
  799.     void _Cdecl open( PCchar,
  800.                       int = ios::in,
  801.                       int = filebuf::openprot
  802.                     );
  803. };
  804.  
  805. /* ------------------------------------------------------------------------*/
  806. /*                                                                         */
  807. /*   class ofpstream                                                       */
  808. /*                                                                         */
  809. /*   Base class for writing streamable objects to file streams             */
  810. /*                                                                         */
  811. /* ------------------------------------------------------------------------*/
  812.  
  813. class _CLASSTYPE ofpstream : public fpbase, public opstream
  814. {
  815.  
  816. public:
  817.  
  818.     _Cdecl ofpstream() {}
  819.     _Cdecl ofpstream( PCchar,
  820.                       int = ios::out,
  821.                       int = filebuf::openprot
  822.                     );
  823.     _Cdecl ofpstream( int f) : fpbase( f ) {}
  824.     _Cdecl ofpstream( int f, Pchar b, int len ) : fpbase(f, b, len) {}
  825.     _Cdecl ~ofpstream() {}
  826.  
  827.     Pfilebuf _Cdecl rdbuf() { return fpbase::rdbuf(); }
  828.     void _Cdecl open( PCchar,
  829.                       int = ios::out,
  830.                       int = filebuf::openprot
  831.                     );
  832.  
  833. };
  834.  
  835. /* ------------------------------------------------------------------------*/
  836. /*                                                                         */
  837. /*   class fpstream                                                        */
  838. /*                                                                         */
  839. /*   Base class for reading and writing streamable objects to              */
  840. /*   bidirectional file streams                                            */
  841. /*                                                                         */
  842. /* ------------------------------------------------------------------------*/
  843.  
  844. class _CLASSTYPE fpstream : public fpbase, public iopstream
  845. {
  846.  
  847. public:
  848.  
  849.     _Cdecl fpstream() {}
  850.     _Cdecl fpstream( PCchar, int, int = filebuf::openprot );
  851.     _Cdecl fpstream( int f) : fpbase( f ) {}
  852.     _Cdecl fpstream( int f, Pchar b, int len ) : fpbase(f, b, len) {}
  853.     _Cdecl ~fpstream() {}
  854.  
  855.     Pfilebuf _Cdecl rdbuf() { return fpbase::rdbuf(); }
  856.     void _Cdecl open( PCchar, int, int = filebuf::openprot );
  857.  
  858. };
  859.  
  860. _CLASSDEF(TWindow)
  861. _CLASSDEF(TScroller)
  862.  
  863. #define MaxInt 32767
  864. long LongMulDiv(long Mult1, long Mult2, long Div1);
  865.  
  866.   /* TScroller object */
  867.  
  868. class _EXPORT TScroller : public Object, public TStreamable
  869. {
  870. public:
  871.     PTWindow Window;
  872.     long XPos, YPos;      // current pos in horz/vert scroll units
  873.     long XRange, YRange;  // # of scrollable horz/vert scroll units
  874.     int XUnit, YUnit;     //logical device units per horz/vert scroll unit
  875.     int XLine, YLine;        // # of horz/vert scroll units per line
  876.     int XPage, YPage;        // # of horz/vert scroll units per page
  877.     BOOL AutoMode;           // auto scrolling mode
  878.     BOOL TrackMode;          // track scroll mode
  879.     BOOL AutoOrg;            // indicates Scroller offsets origin
  880.     BOOL HasHScrollBar;
  881.     BOOL HasVScrollBar;
  882.  
  883.     TScroller(PTWindow TheWindow, int TheXUnit, int TheYUnit,
  884.               long TheXRange, long TheYRange);
  885.     ~TScroller();
  886.     void SetUnits(int TheXUnit, int TheYUnit);
  887.     virtual void SetPageSize();
  888.     virtual void SetSBarRange();
  889.     void SetRange(long TheXRange, long TheYRange);
  890. #if defined(WIN31)
  891.     // windows 3.1 interface
  892.     virtual void BeginView(HDC PaintDC, PAINTSTRUCT _FAR & PaintInfo);
  893. #endif
  894. #if defined(WIN30)
  895.     // windows 3.0 interface
  896.     virtual void BeginView(HDC_30 PaintDC, PAINTSTRUCT _FAR & PaintInfo);
  897. #endif
  898. #if (defined(WIN30) || defined(WIN31)) && !(defined(WIN30) && defined(WIN31))
  899.     // this function is never called. it is used to pad the vtable so that
  900.     // exactly two BeginView(...) definitions are always present.
  901.     virtual void BeginView(void *, void *) { };
  902. #endif
  903.     virtual void EndView();
  904.     virtual void VScroll(WORD ScrollEvent, int ThumbPos);
  905.     virtual void HScroll(WORD ScrollEvent, int ThumbPos);
  906.     virtual void ScrollTo(long X, long Y);
  907.  
  908.     /* Scrolls to a position calculated using the passed
  909.        "Delta" values. */
  910.     void ScrollBy(long Dx, long Dy)
  911.         { ScrollTo(XPos + Dx, YPos + Dy); }
  912.  
  913.     virtual void AutoScroll();
  914.  
  915.     /* Returns a BOOL value indicating whether or not the passed
  916.        area (in units) is currently visible. */
  917.     BOOL IsVisibleRect(long X, long Y, int XExt, int YExt)
  918.         { return (X + XExt >= XPos) && (Y + YExt >= YPos) &&
  919.              (X < XPos + XPage) && (Y < YPos + YPage); }
  920.  
  921.     /* Converts a horizontal range value from the scrollbar to a
  922.        horizontal scroll value. */
  923.     int XScrollValue(long ARangeUnit)
  924.         { return (int)LongMulDiv(ARangeUnit, MaxInt, XRange); }
  925.  
  926.     /* Converts a vertical range value from the scrollbar to a
  927.        vertical scroll value. */
  928.     int YScrollValue(long ARangeUnit)
  929.         { return (int)LongMulDiv(ARangeUnit, MaxInt, YRange); }
  930.  
  931.     /* Converts a horizontal scroll value from the scrollbar to
  932.        a horizontal range value. */
  933.     long XRangeValue(int AScrollUnit)
  934.         { return LongMulDiv(AScrollUnit, XRange, MaxInt); }
  935.  
  936.     /* Converts a vertical scroll value from the scrollbar to
  937.        a vertical range value. */
  938.     long YRangeValue(int AScrollUnit)
  939.         { return LongMulDiv(AScrollUnit, YRange, MaxInt); }
  940.  
  941.     // define pure virtual functions derived from Object class
  942.     virtual classType      isA() const
  943.         { return scrollerClass; }
  944.     virtual Pchar nameOf() const
  945.         { return "TScroller"; }
  946.     virtual hashValueType hashValue() const
  947.         { return InstanceHashValue; }
  948.     virtual int       isEqual(RCObject testobj)  const
  949.         { return (this ==  &(RTScroller)testobj); }
  950.     virtual void         printOn(Rostream outputStream) const
  951.         { outputStream << nameOf() << "{ Window = " << Window <<" }\n";}
  952.  
  953.     static PTStreamable build();
  954.  
  955. protected:
  956.     TScroller(StreamableInit) {};
  957.     virtual void write (Ropstream os);
  958.     virtual Pvoid read (Ripstream is);
  959.     hashValueType InstanceHashValue;
  960.     static hashValueType ClassHashValue;
  961.  
  962. private:
  963.     virtual const Pchar streamableName() const
  964.         { return "TScroller"; }
  965.     
  966.     void __BeginView(HDC PaintDC, PAINTSTRUCT _FAR & PaintInfo);    
  967. };
  968.  
  969. inline Ripstream operator >> ( Ripstream is, RTScroller cl )
  970.     { return is >> (RTStreamable )cl; }
  971. inline Ripstream operator >> ( Ripstream is, RPTScroller cl )
  972.     { return is >> (RPvoid)cl; }
  973.  
  974. inline Ropstream operator << ( Ropstream os, RTScroller cl )
  975.     { return os << (RTStreamable )cl; }
  976. inline Ropstream operator << ( Ropstream os, PTScroller cl )
  977.     { return os << (PTStreamable )cl; }
  978.  
  979. //  windows 3.1 name confict with TWindowsObject::GetFirstChild()
  980. #if defined(GetFirstChild)
  981. #undef GetFirstChild(hwnd)
  982. #endif
  983.  
  984. struct TMessage {
  985.   HWND Receiver;
  986.   WORD Message;
  987.   union {
  988.     WORD WParam;
  989.         struct tagWP {
  990.           BYTE Lo;
  991.           BYTE Hi;
  992.         } WP;
  993.   };
  994.   union {
  995.         DWORD LParam;
  996.         struct tagLP {
  997.           WORD Lo;
  998.           WORD Hi;
  999.         } LP;
  1000.   };
  1001.   long Result;
  1002. };
  1003.  
  1004. _CLASSDEF(TMDIClient)
  1005. _CLASSDEF(TApplication)
  1006. _CLASSDEF(TModule)
  1007. _CLASSDEF(TWindowsObject)
  1008.  
  1009.  
  1010. typedef TMessage _FAR &RTMessage;
  1011.  
  1012. typedef void ( _FAR *TActionFunc )(Pvoid Child, Pvoid ParamList);
  1013. typedef BOOL ( _FAR *TCondFunc )(Pvoid Child, Pvoid ParamList);
  1014.  
  1015. /* TWindowsObject */
  1016. class _EXPORT TWindowsObject : public Object, public TStreamable
  1017. {
  1018. public:
  1019.     int Status;
  1020.     HWND HWindow;    // handle to associated MS-Windows window
  1021.     LPSTR Title;
  1022.     PTWindowsObject Parent;
  1023.  
  1024.     TWindowsObject(PTWindowsObject AParent, PTModule AModule = NULL);
  1025.     virtual ~TWindowsObject();
  1026.     void SetFlags(WORD Mask, BOOL OnOff);
  1027.  
  1028.     /* Determines whether the flag whose mask is passed has been set,
  1029.        returning a BOOL indicator --  True = On, False = Off. */
  1030.     BOOL IsFlagSet(WORD Mask)
  1031.         { return( (Flags & Mask) == Mask); }
  1032.  
  1033.     PTWindowsObject FirstThat(TCondFunc Test, Pvoid PParamList);
  1034.     void ForEach(TActionFunc Action, Pvoid PParamList);
  1035.     PTWindowsObject FirstThat(
  1036.         BOOL (TWindowsObject::* _FAR Test)(Pvoid, Pvoid), Pvoid PParamList);
  1037.     void ForEach(
  1038.         void (TWindowsObject::* _FAR Action)(Pvoid, Pvoid), Pvoid PParamList);
  1039.  
  1040.     PTWindowsObject Next();
  1041.     PTWindowsObject GetFirstChild()
  1042.         { return ChildList->SiblingList; }
  1043.     PTWindowsObject GetLastChild()
  1044.         { return ChildList; }
  1045.     PTWindowsObject Previous();
  1046.     void EnableKBHandler();
  1047.     void EnableAutoCreate();
  1048.     void DisableAutoCreate();
  1049.     void EnableTransfer();
  1050.     void DisableTransfer();
  1051.  
  1052.     PTModule GetModule()
  1053.         { return Module; }
  1054.     PTApplication GetApplication()
  1055.         { return Application; }
  1056.     WNDPROC GetInstance()
  1057.         { return Instance; }
  1058.     virtual BOOL Register();
  1059.  
  1060. /* Pure virtual function, placeholder for derived classes to redefine to
  1061.    create an MS_Windows element to be associated with an OWL window
  1062.    object */
  1063.     virtual BOOL Create() = 0;
  1064.  
  1065.     virtual void Destroy();
  1066.  
  1067.     virtual int GetId();
  1068.     PTWindowsObject ChildWithId(int Id);
  1069.     virtual PTMDIClient GetClient();
  1070.     virtual void SetParent(PTWindowsObject NewParent);
  1071.     void Show(int ShowCmd);
  1072.     void SetCaption(LPSTR ATitle);
  1073.     virtual BOOL CanClose();
  1074.     void SetTransferBuffer(Pvoid ATransferBuffer)
  1075.         { TransferBuffer = ATransferBuffer; }
  1076.     virtual WORD Transfer(Pvoid DataPtr, WORD TransferFlag);
  1077.     virtual void TransferData(WORD Direction);
  1078.     virtual void DefWndProc(RTMessage Msg);
  1079.     virtual void BeforeDispatchHandler() {}
  1080.     virtual void AfterDispatchHandler() {}
  1081.     virtual void DispatchAMessage(WORD AMsg, RTMessage AMessage,
  1082.         void (TWindowsObject::* _FAR)(RTMessage ));
  1083.     void CloseWindow();
  1084.     void GetChildren(Ripstream is);
  1085.     void PutChildren(Ropstream os);
  1086.     BOOL CreateChildren();
  1087.     virtual void ShutDownWindow();
  1088.     virtual void DrawItem(DRAWITEMSTRUCT far & DrawInfo);
  1089.     virtual void ActivationResponse(WORD Activated, BOOL IsIconified);
  1090.  
  1091.     // define pure virtual functions derived from Object class
  1092.     virtual classType      isA() const = 0;
  1093.     virtual Pchar nameOf() const = 0;
  1094.     virtual hashValueType  hashValue() const
  1095.         { return hashValueType(HWindow); }
  1096.     virtual int              isEqual(RCObject testwin)  const
  1097.         { return this ==  &(RTWindowsObject)testwin; }
  1098.     virtual void             printOn(Rostream outputStream) const
  1099.     { outputStream << nameOf() << "{ HWindow = "
  1100.          << (void _FAR *)HWindow << " }\n"; }
  1101.  
  1102.     static PTStreamable build();
  1103.  
  1104. protected:
  1105.  
  1106.     WNDPROC DefaultProc;
  1107.     Pvoid TransferBuffer;
  1108.     virtual void GetWindowClass(WNDCLASS _FAR & AWndClass);
  1109.     virtual LPSTR GetClassName() = 0;
  1110.     void RemoveClient()
  1111.         { RemoveChild((PTWindowsObject)GetClient()); }
  1112.     void GetChildPtr(Ripstream is, RPTWindowsObject P);
  1113.     void PutChildPtr(Ropstream os, PTWindowsObject P);
  1114.     void GetSiblingPtr(Ripstream is, RPTWindowsObject P);
  1115.     void PutSiblingPtr(Ropstream os, PTWindowsObject P);
  1116.     virtual void DefCommandProc(RTMessage Msg);
  1117.     virtual void DefChildProc(RTMessage Msg);
  1118.     virtual void DefNotificationProc(RTMessage Msg);
  1119.     virtual void SetupWindow();
  1120.     virtual void WMVScroll(RTMessage Msg) =
  1121.                  [WM_FIRST + WM_VSCROLL];
  1122.     virtual void WMHScroll(RTMessage Msg) =
  1123.                  [WM_FIRST + WM_HSCROLL];
  1124.     void DispatchScroll(RTMessage Msg);
  1125.     virtual void WMCommand(RTMessage Msg) =
  1126.                  [WM_FIRST + WM_COMMAND];
  1127.     virtual void WMDrawItem(RTMessage Msg) =
  1128.                  [WM_FIRST + WM_DRAWITEM];
  1129.     virtual void WMClose(RTMessage Msg) =
  1130.                  [WM_FIRST + WM_CLOSE];
  1131.     virtual void WMDestroy(RTMessage Msg) =
  1132.                  [WM_FIRST + WM_DESTROY];
  1133.     virtual void WMNCDestroy(RTMessage Msg) =
  1134.                  [WM_FIRST + WM_NCDESTROY];
  1135.     virtual void WMActivate(RTMessage Msg) =
  1136.                  [WM_FIRST + WM_ACTIVATE];
  1137.     virtual void WMQueryEndSession(RTMessage Msg) =
  1138.                  [WM_FIRST + WM_QUERYENDSESSION];
  1139.     virtual void CMExit(RTMessage Msg) =
  1140.                  [CM_FIRST + CM_EXIT];
  1141.  
  1142.     TWindowsObject(StreamableInit) {};
  1143.     virtual void write (Ropstream os);
  1144.     virtual Pvoid read (Ripstream is);
  1145.  
  1146. private:
  1147.  
  1148.     WNDPROC Instance;
  1149.     PTApplication Application;
  1150.     PTModule Module;
  1151.     WORD Flags;
  1152.     WORD CreateOrder;
  1153.     BOOL OrderIsI(Pvoid P, Pvoid I);
  1154.     BOOL CreateZeroChild(Pvoid P, Pvoid I);
  1155.     void AssignCreateOrder();
  1156.     PTWindowsObject ChildList, SiblingList;
  1157.     void AddChild(PTWindowsObject AChild);
  1158.     void RemoveChild(PTWindowsObject AChild);
  1159.     int IndexOf(PTWindowsObject P);
  1160.     PTWindowsObject At(int APosition);
  1161.  
  1162.     virtual const Pchar streamableName() const
  1163.         { return "TWindowsObject"; }
  1164.  
  1165. };    // end of WindowsObject class
  1166.  
  1167. /* Returns the Id of the TWindowsObject, used to identify the window
  1168.    in a specified parent's ChildList.  Redefined by TControl
  1169.    descendants to return their identifier from their attributes
  1170.    structure.  0 is returned here as the default identifier. This
  1171.    precludes any window with a 0 Id from being easily found. If you
  1172.    need to address individual windows, redefine GetId to return
  1173.    something other than 0.*/
  1174. inline int TWindowsObject::GetId()
  1175.         { return 0; }
  1176.  
  1177. /* Returns a pointer to the TWindowsObject's next sibling (the next
  1178.    window in its parent's child window list.  If this was the last child
  1179.    added to the list, returns a pointer to the first child added.*/
  1180. inline PTWindowsObject TWindowsObject::Next()
  1181.         { return SiblingList; }
  1182.  
  1183. typedef void ( TWindowsObject::* _FAR TActionMemFunc )(Pvoid Child, Pvoid ParamList);
  1184. typedef BOOL ( TWindowsObject::* _FAR TCondMemFunc )(Pvoid Child, Pvoid ParamList);
  1185.  
  1186. inline Ripstream operator >> ( Ripstream is, RTWindowsObject cl )
  1187.     { return is >> (RTStreamable)cl; }
  1188. inline Ripstream operator >> ( Ripstream is, RPTWindowsObject cl )
  1189.     { return is >> (RPvoid)cl; }
  1190.  
  1191. inline Ropstream operator << ( Ropstream os, RTWindowsObject cl )
  1192.     { return os << (RTStreamable )cl; }
  1193. inline Ropstream operator << ( Ropstream os, PTWindowsObject cl )
  1194.     { return os << (PTStreamable )cl; }
  1195.  
  1196. const int BAD_DIALOG_STATUS = -2;
  1197.  
  1198. /* TDialog creation atributes */
  1199. struct _CLASSTYPE TDialogAttr { // _CLASSTYPE needed by BC++ 2.0
  1200.     LPSTR Name;
  1201.     DWORD Param;
  1202. };
  1203.  
  1204.   /* TDialog */
  1205.  
  1206. _CLASSDEF(TDialog)
  1207.  
  1208. class _EXPORT TDialog : public TWindowsObject
  1209. {
  1210. public:
  1211.     TDialogAttr Attr;
  1212.     BOOL IsModal;
  1213.  
  1214.     TDialog(PTWindowsObject AParent, LPSTR AName, PTModule AModule = NULL);
  1215.     TDialog(PTWindowsObject AParent, int ResourceId, PTModule AModule = NULL);
  1216.     virtual ~TDialog();
  1217.  
  1218.     virtual BOOL Create();
  1219.     virtual int Execute();
  1220.  
  1221.     virtual void CloseWindow(int ARetValue);
  1222.     virtual void CloseWindow();
  1223.     virtual void ShutDownWindow(int ARetValue);
  1224.     virtual void ShutDownWindow();
  1225.     virtual void Destroy(int ARetValue);
  1226.     virtual void Destroy();
  1227.  
  1228.     void SetCaption(LPSTR ATitle);
  1229.  
  1230. /* Returns the handle of the dialog's control with the passed Id.*/
  1231.     HWND GetItemHandle(int DlgItemID)
  1232.       { return GetDlgItem(HWindow, DlgItemID); }
  1233.  
  1234. /* Sends the passed message to the dialog's control which has
  1235.    the Id DlgItemID. */
  1236.     DWORD SendDlgItemMsg(int DlgItemID, WORD AMsg, WORD WParam, DWORD LParam)
  1237.       { return SendDlgItemMessage(HWindow, DlgItemID, AMsg, WParam, LParam); }
  1238.  
  1239.  
  1240.     virtual classType        isA() const
  1241.     { return dialogClass; }
  1242.     virtual Pchar nameOf() const
  1243.         { return "TDialog"; }
  1244.  
  1245.     static PTStreamable build();
  1246.  
  1247. protected:
  1248.     virtual void GetWindowClass(WNDCLASS _FAR & AWndClass);
  1249.     virtual LPSTR GetClassName();
  1250.     virtual void SetupWindow();
  1251.     virtual void Ok(RTMessage Msg) = [ID_FIRST + IDOK];
  1252.     virtual void Cancel(RTMessage Msg) = [ID_FIRST + IDCANCEL];
  1253.     virtual void WMInitDialog(RTMessage Msg) = [WM_FIRST + WM_INITDIALOG];
  1254.     virtual void WMQueryEndSession(RTMessage Msg) =
  1255.                  [WM_FIRST + WM_QUERYENDSESSION];
  1256.     virtual void WMClose(RTMessage Msg) = [WM_FIRST + WM_CLOSE];
  1257.  
  1258.     TDialog(StreamableInit) : TWindowsObject(streamableInit) {};
  1259.     virtual void write (Ropstream os);
  1260.     virtual Pvoid read (Ripstream is);
  1261.  
  1262. private:
  1263.     virtual const Pchar streamableName() const
  1264.         { return "TDialog"; }
  1265. };
  1266.  
  1267. inline Ripstream operator >> ( Ripstream is, RTDialog cl )
  1268.     { return is >> (RTStreamable)cl; }
  1269. inline Ripstream operator >> ( Ripstream is, RPTDialog cl )
  1270.     { return is >> (RPvoid)cl; }
  1271.  
  1272. inline Ropstream operator << ( Ropstream os, RTDialog cl )
  1273.     { return os << (RTStreamable )cl; }
  1274. inline Ropstream operator << ( Ropstream os, PTDialog cl )
  1275.     { return os << (PTStreamable)cl; }
  1276.  
  1277.   /* TWindow creation attributes */
  1278. struct _CLASSTYPE TWindowAttr { // _CLASSTYPE needed by BC++ 2.0
  1279.     DWORD Style;
  1280.     DWORD ExStyle;
  1281.     int X, Y, W, H;
  1282.     LPSTR Menu;  // Menu name
  1283.     int Id ;     // Child identifier
  1284.     LPSTR Param;
  1285.  };
  1286.  
  1287.  
  1288. /* Window Class */
  1289.  
  1290. _CLASSDEF(TWindow)
  1291.  
  1292. class _EXPORT TWindow : public TWindowsObject
  1293. {
  1294. public:
  1295.     TWindowAttr  Attr;
  1296.     PTScroller Scroller;
  1297.     HWND FocusChildHandle;
  1298.  
  1299.     TWindow(PTWindowsObject AParent, LPSTR ATitle, PTModule AModule = NULL);
  1300.     TWindow(HWND AnHWindow, PTModule AModule = NULL);
  1301.     virtual ~TWindow();
  1302.  
  1303.     virtual BOOL AssignMenu(LPSTR MenuName);
  1304.     virtual BOOL AssignMenu(int MenuId);
  1305.     virtual BOOL Create();
  1306.     virtual void ActivationResponse(WORD Activated, BOOL IsIconified);
  1307.  
  1308.     virtual classType        isA() const
  1309.     { return windowClass; }
  1310.     virtual Pchar nameOf() const
  1311.     { return "TWindow"; }
  1312.  
  1313.     static PTStreamable build();
  1314.  
  1315. protected:
  1316.     virtual LPSTR GetClassName()
  1317.         { return "OWLWindow31"; }
  1318.     virtual void GetWindowClass(WNDCLASS _FAR & AWndClass);
  1319.     virtual void SetupWindow();
  1320.  
  1321.     virtual void WMCreate(RTMessage Msg) = [WM_FIRST + WM_CREATE];
  1322.     virtual void WMMDIActivate(RTMessage Msg) =
  1323.                  [WM_FIRST + WM_MDIACTIVATE];
  1324.     virtual void WMHScroll(RTMessage Msg) = [WM_FIRST + WM_HSCROLL];
  1325.     virtual void WMVScroll(RTMessage Msg) = [WM_FIRST + WM_VSCROLL];
  1326.     virtual void WMPaint(RTMessage Msg) = [WM_FIRST + WM_PAINT];
  1327. #if defined(WIN31)
  1328.     // windows 3.1 interface
  1329.     virtual void Paint(HDC PaintDC, PAINTSTRUCT _FAR & PaintInfo);
  1330. #endif
  1331. #if defined(WIN30)
  1332.     // windows 3.0 interface
  1333.     virtual void Paint(HDC_30 PaintDC, PAINTSTRUCT _FAR & PaintInfo);
  1334. #endif
  1335. #if (defined(WIN30) || defined(WIN31)) && !(defined(WIN30) && defined(WIN31))
  1336.     // this function is never called. it is used to pad the vtable so that
  1337.     // exactly two Paint(...) definitions are always present.
  1338.     virtual void Paint(void *, void *) { };
  1339. #endif
  1340.     virtual void WMSize(RTMessage Msg) = [WM_FIRST + WM_SIZE];
  1341.     virtual void WMMove(RTMessage Msg) = [WM_FIRST + WM_MOVE];
  1342.     virtual void WMLButtonDown(RTMessage Msg) = [WM_FIRST + WM_LBUTTONDOWN];
  1343.  
  1344.     TWindow(StreamableInit) : TWindowsObject(streamableInit) {};
  1345.     virtual void write (Ropstream os);
  1346.     virtual Pvoid read (Ripstream is);
  1347.  
  1348. private:
  1349.     virtual const Pchar streamableName() const
  1350.         { return "TWindow"; }
  1351.  
  1352. };     // end of Window class
  1353.  
  1354. inline Ripstream operator >> ( Ripstream is, RTWindow cl )
  1355.     { return is >> (RTStreamable)cl; }
  1356. inline Ripstream operator >> ( Ripstream is, RPTWindow cl )
  1357.     { return is >> (RPvoid)cl; }
  1358.  
  1359. inline Ropstream operator << ( Ropstream os, RTWindow cl )
  1360.     { return os << (RTStreamable)cl; }
  1361. inline Ropstream operator << ( Ropstream os, PTWindow cl )
  1362.     { return os << (PTStreamable)cl; }
  1363.  
  1364. #define FILESPEC    MAXPATH + MAXEXT
  1365.  
  1366. _CLASSDEF(TFileDialog)
  1367.  
  1368.   /* TFileDialog */
  1369. class _EXPORT TFileDialog : public TDialog
  1370. {
  1371. public:
  1372.     LPSTR FilePath;
  1373.     char PathName[MAXPATH];
  1374.     char Extension[MAXEXT];
  1375.     char FileSpec[FILESPEC];
  1376.  
  1377.     TFileDialog(PTWindowsObject AParent, int ResourceId, LPSTR AFilePath,
  1378.                 PTModule AModule = NULL);
  1379.     virtual BOOL CanClose();
  1380.     void SelectFileName();
  1381.     void UpdateFileName();
  1382.     BOOL UpdateListBoxes();
  1383.  
  1384.     static PTStreamable build();
  1385.  
  1386. protected:
  1387.     virtual void SetupWindow();
  1388.     virtual void HandleFName(RTMessage Msg)
  1389.           = [ID_FIRST + ID_FNAME];
  1390.     virtual void HandleFList(RTMessage Msg)
  1391.           = [ID_FIRST + ID_FLIST];
  1392.     virtual void HandleDList(RTMessage Msg)
  1393.           = [ID_FIRST + ID_DLIST];
  1394.  
  1395.     TFileDialog(StreamableInit) : TDialog(streamableInit) {};
  1396.  
  1397. private:
  1398.     virtual const Pchar streamableName() const
  1399.         { return "TFileDialog"; }
  1400. };
  1401.  
  1402. inline Ripstream operator >> ( Ripstream is, RTFileDialog cl )
  1403.     { return is >> (RTStreamable )cl; }
  1404. inline Ripstream operator >> ( Ripstream is, RPTFileDialog cl )
  1405.     { return is >> (RPvoid)cl; }
  1406.  
  1407. inline Ropstream operator << ( Ropstream os, RTFileDialog cl )
  1408.     { return os << (RTStreamable )cl; }
  1409. inline Ropstream operator << ( Ropstream os, PTFileDialog cl )
  1410.     { return os << (PTStreamable )cl; }
  1411.  
  1412. _CLASSDEF(TInputDialog)
  1413.  
  1414.   /* TInputDialog */
  1415. class _EXPORT TInputDialog : public TDialog
  1416. {
  1417. public:
  1418.     LPSTR Prompt;
  1419.     LPSTR Buffer;
  1420.     WORD BufferSize;
  1421.  
  1422.     TInputDialog(PTWindowsObject AParent, LPSTR ATitle,
  1423.               LPSTR APrompt, LPSTR ABuffer, WORD ABufferSize,
  1424.               PTModule AModule = NULL);
  1425.     void TransferData(WORD Direction);
  1426.  
  1427.     static PTStreamable build();
  1428.  
  1429. protected:
  1430.     virtual void SetupWindow();
  1431.     TInputDialog(StreamableInit) : TDialog(streamableInit) {};
  1432.     virtual void write (Ropstream os);
  1433.     virtual Pvoid read (Ripstream is);
  1434.  
  1435. private:
  1436.     virtual const Pchar streamableName() const
  1437.         { return "TInputDialog"; }
  1438. };
  1439.  
  1440. inline Ripstream operator >> ( Ripstream is, RTInputDialog cl )
  1441.     { return is >> (RTStreamable )cl; }
  1442. inline Ripstream operator >> ( Ripstream is, RPTInputDialog cl )
  1443.     { return is >> (RPvoid)cl; }
  1444.  
  1445. inline Ropstream operator << ( Ropstream os, RTInputDialog cl )
  1446.     { return os << (RTStreamable )cl; }
  1447. inline Ropstream operator << ( Ropstream os, PTInputDialog cl )
  1448.     { return os << (PTStreamable )cl; }
  1449.  
  1450. _CLASSDEF(TBWindow)
  1451.  
  1452. /* TBWindow */
  1453.  
  1454. class _EXPORT TBWindow : public TWindow
  1455. {
  1456. public:
  1457.     TBWindow(PTWindowsObject AParent, LPSTR AName,
  1458.          PTModule AModule = NULL);
  1459.  
  1460.     static PTStreamable build();
  1461.  
  1462. protected:
  1463.     virtual LPSTR GetClassName()
  1464.         {return "TBWindow";}
  1465.     virtual void GetWindowClass(WNDCLASS _FAR & AWndClass);
  1466.  
  1467.     TBWindow(StreamableInit) : TWindow(streamableInit) {};
  1468.  
  1469. private:
  1470.     virtual const Pchar streamableName() const
  1471.         { return "TBWindow"; }
  1472. };
  1473.  
  1474. inline Ripstream operator >> ( Ripstream is, RTBWindow cl )
  1475.     { return is >> (RTStreamable)cl; }
  1476. inline Ripstream operator >> ( Ripstream is, RPTBWindow cl )
  1477.     { return is >> (RPvoid)cl; }
  1478.  
  1479. inline Ropstream operator << ( Ropstream os, RTBWindow cl )
  1480.     { return os << (RTStreamable)cl; }
  1481. inline Ropstream operator << ( Ropstream os, PTBWindow cl )
  1482.     { return os << (PTStreamable)cl; }
  1483.  
  1484.   /* TControl */
  1485.  
  1486. _CLASSDEF(TControl)
  1487.  
  1488. class _EXPORT TControl : public TWindow {
  1489. public:
  1490.     TControl(PTWindowsObject AParent, int AnId, LPSTR ATitle, int X,
  1491.              int Y, int W, int H, PTModule AModule = NULL);
  1492.     TControl(PTWindowsObject AParent, int ResourceId,
  1493.          PTModule AModule = NULL);
  1494.     virtual int GetId()
  1495.         { return Attr.Id; }
  1496.  
  1497. protected:
  1498.     TControl(StreamableInit) : TWindow(streamableInit) {};
  1499.  
  1500.     virtual void WMPaint(RTMessage Msg) = [WM_FIRST + WM_PAINT];
  1501.     virtual void WMDrawItem(RTMessage Msg) = [WM_FIRST + WM_DRAWITEM];
  1502.     virtual void ODADrawEntire(DRAWITEMSTRUCT far & DrawInfo);
  1503.     virtual void ODAFocus(DRAWITEMSTRUCT far & DrawInfo);
  1504.     virtual void ODASelect(DRAWITEMSTRUCT far & DrawInfo);
  1505. };
  1506.  
  1507. _CLASSDEF(TMDIFrame)
  1508. _CLASSDEF(TMDIClient)
  1509.  
  1510. /* --------------------------------------------------------
  1511.   TMDIClient object
  1512.   -------------------------------------------------------- */
  1513.  
  1514. class _EXPORT TMDIClient : public TWindow
  1515. {
  1516. public:
  1517.     LPCLIENTCREATESTRUCT ClientAttr;
  1518.  
  1519.     TMDIClient(PTMDIFrame AParent, PTModule AModule = NULL);
  1520.     TMDIClient(PTMDIFrame AParent, HWND AnHWindow, PTModule AModule = NULL);
  1521.     virtual ~TMDIClient();
  1522.  
  1523.     /* Arranges iconized MDI child windows. */
  1524.     virtual void ArrangeIcons()
  1525.     { SendMessage(HWindow, WM_MDIICONARRANGE, 0, 0); }
  1526.  
  1527.     /* Cascades the MDI child windows. */
  1528.     virtual void CascadeChildren()
  1529.     { SendMessage(HWindow, WM_MDICASCADE, 0, 0); }
  1530.  
  1531.     /* Tiles the MDI child windows. */
  1532.     virtual void TileChildren()
  1533.     { SendMessage(HWindow, WM_MDITILE, 0, 0); }
  1534.  
  1535.     static PTStreamable build();
  1536.  
  1537. protected:
  1538.     virtual LPSTR GetClassName()
  1539.         { return "MDICLIENT"; }
  1540.  
  1541.     /* Override TWindow::WMPaint and instead call DefWndProc */
  1542.     virtual void WMPaint(RTMessage Msg) = [WM_FIRST + WM_PAINT]
  1543.         { DefWndProc(Msg); }
  1544.  
  1545.     /* Override TWindow::WMMDIActivate, instead just call DefWndProc. */
  1546.     virtual void WMMDIActivate(RTMessage Msg) =
  1547.                  [WM_FIRST + WM_MDIACTIVATE]
  1548.         { DefWndProc(Msg); }
  1549.  
  1550.     TMDIClient(StreamableInit) : TWindow(streamableInit) {}
  1551.     virtual void write (Ropstream os);
  1552.     virtual Pvoid read (Ripstream is);
  1553.  
  1554. private:
  1555.     virtual const Pchar streamableName() const
  1556.         { return "TMDIClient"; }
  1557. };
  1558.  
  1559. inline Ripstream operator >> ( Ripstream is, RTMDIClient cl )
  1560.     { return is >> (RTStreamable)cl; }
  1561. inline Ripstream operator >> ( Ripstream is, RPTMDIClient cl )
  1562.     { return is >> (RPvoid)cl; }
  1563.  
  1564. inline Ropstream operator << ( Ropstream os, RTMDIClient cl )
  1565.     { return os << (RTStreamable)cl; }
  1566. inline Ropstream operator << ( Ropstream os, PTMDIClient cl )
  1567.     { return os << (PTStreamable)cl; }
  1568.  
  1569. /* --------------------------------------------------------
  1570.   TMDIFrame object
  1571.   -------------------------------------------------------- */
  1572.  
  1573. class _EXPORT TMDIFrame : public TWindow
  1574. {
  1575. public:
  1576.     PTMDIClient ClientWnd;     // MDI client window
  1577.     int ChildMenuPos;          // menu position for child menu
  1578.     PTWindow ActiveChild;
  1579.  
  1580.     TMDIFrame(LPSTR ATitle, LPSTR MenuName, PTModule AModule = NULL);
  1581.     TMDIFrame(LPSTR ATitle, int MenuId, PTModule AModule = NULL);
  1582.     TMDIFrame(HWND AnHWindow, HWND ClientHWnd, PTModule AModule = NULL);
  1583.     virtual ~TMDIFrame();
  1584.  
  1585.     /* Constructs the TMDIFrame's MDI client window. */
  1586.     virtual void InitClientWindow()
  1587.         { ClientWnd = new TMDIClient(this); }
  1588.  
  1589.     /* Returns a pointer to the TMDIFrame's MDI client window. */
  1590.     virtual PTMDIClient GetClient()
  1591.         { return ClientWnd; }
  1592.  
  1593.     /* Constructs a new MDI child window object.  By default,
  1594.       constructs an instance of TWindow as an MDI child window object.
  1595.       Will almost always be redefined by descendants to construct an
  1596.       instance of a user-defined TWindow descendant as an MDI child
  1597.       window object. */
  1598.     virtual PTWindowsObject InitChild()
  1599.         { return new TWindow(this, ""); }
  1600.  
  1601.     virtual PTWindowsObject CreateChild();
  1602.  
  1603.     /* Tiles the MDI child windows by calling the TileChildren method
  1604.       of the MDI client window object. */
  1605.     virtual void TileChildren()
  1606.         { ClientWnd->TileChildren(); }
  1607.  
  1608.     /* Cascades the MDI child windows by calling the CascadeChildren
  1609.       method of the MDI client window object. */
  1610.     virtual void CascadeChildren()
  1611.         { ClientWnd->CascadeChildren(); }
  1612.  
  1613.     /* Arranges iconized MDI child windows by calling the
  1614.       ArrangeIcons method of the MDI client window object. */
  1615.     virtual void ArrangeIcons()
  1616.         { ClientWnd->ArrangeIcons(); }
  1617.  
  1618.     virtual BOOL CloseChildren();
  1619.     static PTStreamable build();
  1620.  
  1621. protected:
  1622.     virtual void GetWindowClass(WNDCLASS _FAR & AWndClass);
  1623.     virtual LPSTR GetClassName()
  1624.         { return "OWLMDIFrame31"; }
  1625.     virtual void SetupWindow();
  1626.  
  1627.     /* Since an MDI child doesn't get MDIACTIVATE messages when the
  1628.        frame gets (de)activated, call its ActivationResponse here. */
  1629.     virtual void WMActivate(RTMessage Msg)
  1630.         { TWindow::WMActivate(Msg);
  1631.           if ( ActiveChild )
  1632.             ActiveChild->ActivationResponse(
  1633.                    Msg.WParam, IsIconic(ActiveChild->HWindow)); }
  1634.  
  1635.     /* Responds to an incoming "CreateChild" command (with a
  1636.       CM_CREATECHILD command identifier) by calling CreateChild to
  1637.       construct and create a new MDI child. */
  1638.     virtual void CMCreateChild(RTMessage) =
  1639.                  [CM_FIRST + CM_CREATECHILD]
  1640.         { CreateChild(); }
  1641.  
  1642.     /* Responds to an incoming "Tile" command (with a CM_TILECHILDREN
  1643.       command identifier) by calling TileChildren to tile the MDI
  1644.       child windows. */
  1645.     virtual void CMTileChildren(RTMessage) =
  1646.                  [CM_FIRST + CM_TILECHILDREN]
  1647.         { TileChildren(); }
  1648.  
  1649.     /* Responds to an incoming "Cascade" command (with a
  1650.       CM_CASCADECHILDREN command identifier) by calling
  1651.       CascadeChildren to cascade the MDI  child windows. */
  1652.     virtual void CMCascadeChildren(RTMessage) =
  1653.                  [CM_FIRST + CM_CASCADECHILDREN]
  1654.         { CascadeChildren(); }
  1655.  
  1656.     /* Responds to an incoming "Arrange" command (with a
  1657.       CM_ARRANGEICONS command identifier) by calling ArrangeIcons
  1658.       to arrange the icons of the MDI child windows. */
  1659.     virtual void CMArrangeIcons(RTMessage) =
  1660.                  [CM_FIRST + CM_ARRANGEICONS]
  1661.         { ArrangeIcons(); }
  1662.  
  1663.     /* Responds to an incoming "CloseAll" command (with a
  1664.       CM_CLOSECHILDREN command identifier) by calling CloseChildren
  1665.       to close the MDI child windows. */
  1666.     virtual void CMCloseChildren(RTMessage) =
  1667.                  [CM_FIRST + CM_CLOSECHILDREN]
  1668.         { CloseChildren(); }
  1669.  
  1670.     TMDIFrame(StreamableInit) : TWindow(streamableInit) {};
  1671.     virtual void write (Ropstream os);
  1672.     virtual Pvoid read (Ripstream is);
  1673.  
  1674. private:
  1675.     virtual const Pchar streamableName() const
  1676.         { return "TMDIFrame"; }
  1677. };
  1678.  
  1679. inline Ripstream operator >> ( Ripstream is, RTMDIFrame cl )
  1680.     { return is >> (RTStreamable)cl; }
  1681. inline Ripstream operator >> ( Ripstream is, RPTMDIFrame cl )
  1682.     { return is >> (RPvoid)cl; }
  1683.  
  1684. inline Ropstream operator << ( Ropstream os, RTMDIFrame cl )
  1685.     { return os << (RTStreamable)cl; }
  1686. inline Ropstream operator << ( Ropstream os, PTMDIFrame cl )
  1687.     { return os << (PTStreamable)cl; }
  1688.  
  1689. _CLASSDEF(TModule)
  1690.  
  1691. // Module Class
  1692.  
  1693. class _EXPORT TModule : public Object {
  1694. public:
  1695.  
  1696.     // Lib and WinMain args
  1697.     HINSTANCE        hInstance;
  1698.     LPSTR        lpCmdLine;
  1699.  
  1700.     int Status;
  1701.     LPSTR Name;
  1702.  
  1703. #if defined(WIN31)
  1704.     TModule(LPSTR AName, HINSTANCE AnInstance, LPSTR ACmdLine);
  1705. #endif
  1706. #if defined(WIN30)
  1707.     TModule(LPSTR AName, HINSTANCE_30 AnInstance, LPSTR ACmdLine);
  1708. #endif
  1709.     virtual ~TModule();
  1710.  
  1711.     BOOL LowMemory();
  1712.     void RestoreMemory();
  1713.     virtual PTWindowsObject ValidWindow(PTWindowsObject AWindowsObject);
  1714.     virtual PTWindowsObject MakeWindow(PTWindowsObject AWindowsObject);
  1715.     virtual int ExecDialog(PTWindowsObject ADialog);
  1716.     HWND GetClientHandle(HWND AnHWindow);
  1717.  
  1718. #if defined(WIN31)
  1719.     // windows 3.1 interface
  1720.     virtual PTWindowsObject GetParentObject(HWND ParentHandle);
  1721. #endif
  1722. #if defined(WIN30)
  1723.     // windows 3.0 interface
  1724.     virtual PTWindowsObject GetParentObject(HWND_30 ParentHandle);
  1725. #endif
  1726. #if (defined(WIN30) || defined(WIN31)) && !(defined(WIN30) && defined(WIN31))
  1727.     // this function is never called. it is used to pad the vtable so that
  1728.     // exactly two GetParentObject(...) definitions are always present.
  1729.     virtual PTWindowsObject GetParentObject(void *)
  1730.             { return NULL; }
  1731. #endif
  1732.     virtual void Error(int ErrorCode);
  1733.  
  1734.     // define pure virtual functions derived from Object class
  1735.     virtual classType        isA() const
  1736.         { return moduleClass; }
  1737.     virtual Pchar nameOf() const
  1738.         { return "TModule"; }
  1739.     virtual hashValueType hashValue() const
  1740.         {  return hashValueType(hInstance); }
  1741.     virtual int       isEqual(RCObject module)  const
  1742.             { return (hInstance == ((RTModule)module).hInstance); }
  1743.     virtual void      printOn(Rostream outputStream) const
  1744.             { outputStream << nameOf() << "{ hInstance = "
  1745.               << (void _FAR *)hInstance << " }\n"; }
  1746. private:
  1747.  
  1748.     PTWindowsObject __GetParentObject(HWND ParentHandle);
  1749.     void __TModule(LPSTR AName, HINSTANCE AnInstance, LPSTR ACmdLine);
  1750.  
  1751. };    // end of Module class
  1752.  
  1753. extern PTModule Module;
  1754.  
  1755. _CLASSDEF(TBDivider)
  1756.  
  1757. /* --------------------------------------------------------
  1758.   TBDivider object
  1759.   -------------------------------------------------------- */
  1760. class _EXPORT TBDivider : public TControl
  1761. {
  1762. public:
  1763.     TBDivider(PTWindowsObject AParent, int AnId, LPSTR AText,
  1764.             int X, int Y, int W, int H, BOOL IsVertical,
  1765.         BOOL IsBump, PTModule AModule = NULL);
  1766.     TBDivider(PTWindowsObject AParent, int ResourceId,
  1767.         PTModule AModule = NULL);
  1768.     static PTStreamable build();
  1769.  
  1770. protected:
  1771.     virtual LPSTR GetClassName()
  1772.         {return "BORSHADE";}
  1773.     TBDivider(StreamableInit) : TControl(streamableInit) {};
  1774.  
  1775. private:
  1776.     virtual const Pchar streamableName() const
  1777.         { return "TBDivider"; }
  1778. };
  1779.  
  1780. inline Ripstream operator >> ( Ripstream is, RTBDivider cl )
  1781.     { return is >> (RTStreamable)cl; }
  1782. inline Ripstream operator >> ( Ripstream is, RPTBDivider cl )
  1783.     { return is >> (RPvoid)cl; }
  1784.  
  1785. inline Ropstream operator << ( Ropstream os, RTBDivider cl )
  1786.     { return os << (RTStreamable)cl; }
  1787. inline Ropstream operator << ( Ropstream os, PTBDivider cl )
  1788.     { return os << (PTStreamable)cl; }
  1789.  
  1790. _CLASSDEF(TBStaticBmp)
  1791.  
  1792. /* --------------------------------------------------------
  1793.   TBStaticBmp object
  1794.   -------------------------------------------------------- */
  1795. class _EXPORT TBStaticBmp : public TControl
  1796. {
  1797. public:
  1798.     TBStaticBmp(PTWindowsObject AParent, int AnId, LPSTR AText,
  1799.             int X, int Y, int W, int H, PTModule AModule = NULL);
  1800.     TBStaticBmp(PTWindowsObject AParent, int ResourceId,
  1801.          PTModule AModule = NULL);
  1802.  
  1803.     static PTStreamable build();
  1804.  
  1805. protected:
  1806.     virtual LPSTR GetClassName()
  1807.         {return "BORBTN";}
  1808.     TBStaticBmp(StreamableInit) : TControl(streamableInit) {};
  1809.  
  1810. private:
  1811.     virtual const Pchar streamableName() const
  1812.         { return "TBStaticBmp"; }
  1813. };
  1814.  
  1815. inline Ripstream operator >> ( Ripstream is, RTBStaticBmp cl )
  1816.     { return is >> (RTStreamable)cl; }
  1817. inline Ripstream operator >> ( Ripstream is, RPTBStaticBmp cl )
  1818.     { return is >> (RPvoid)cl; }
  1819.  
  1820. inline Ropstream operator << ( Ropstream os, RTBStaticBmp cl )
  1821.     { return os << (RTStreamable)cl; }
  1822. inline Ropstream operator << ( Ropstream os, PTBStaticBmp cl )
  1823.     { return os << (PTStreamable)cl; }
  1824.  
  1825. /* --------------------------------------------------------
  1826.   TButton object
  1827.   -------------------------------------------------------- */
  1828.  
  1829. _CLASSDEF(TButton)
  1830.  
  1831. class _EXPORT TButton : public TControl
  1832. {
  1833. public:
  1834.     BOOL IsDefPB;
  1835.  
  1836.     TButton(PTWindowsObject AParent, int AnId, LPSTR AText,
  1837.             int X, int Y, int W, int H, BOOL IsDefault,
  1838.         PTModule AModule = NULL);
  1839.     TButton(PTWindowsObject AParent, int ResourceId,
  1840.         PTModule AModule = NULL);
  1841.  
  1842.     static PTStreamable build();
  1843.     virtual void write (Ropstream os);
  1844.     virtual Pvoid read (Ripstream is);
  1845.  
  1846. protected:
  1847.     BOOL IsCurrentDefPB;
  1848.  
  1849.     virtual LPSTR GetClassName()
  1850.         { return "BUTTON"; }
  1851.     virtual void SetupWindow();
  1852.  
  1853.     virtual void WMGetDlgCode(RTMessage Msg) =
  1854.                          [WM_FIRST + WM_GETDLGCODE];
  1855.     virtual void BMSetStyle(RTMessage Msg) = [WM_FIRST + BM_SETSTYLE];
  1856.  
  1857.     TButton(StreamableInit) : TControl(streamableInit) {};
  1858.  
  1859. private:
  1860.     virtual const Pchar streamableName() const
  1861.         { return "TButton"; }
  1862. };
  1863.  
  1864. inline Ripstream operator >> ( Ripstream is, RTButton cl )
  1865.     { return is >> (RTStreamable)cl; }
  1866. inline Ripstream operator >> ( Ripstream is, RPTButton cl )
  1867.     { return is >> (RPvoid)cl; }
  1868.  
  1869. inline Ropstream operator << ( Ropstream os, RTButton cl )
  1870.     { return os << (RTStreamable)cl; }
  1871. inline Ropstream operator << ( Ropstream os, PTButton cl )
  1872.     { return os << (PTStreamable)cl; }
  1873.  
  1874. /* --------------------------------------------------------
  1875.   TBButton object
  1876.   -------------------------------------------------------- */
  1877.  
  1878. _CLASSDEF(TBButton)
  1879.  
  1880. class _EXPORT TBButton : public TButton
  1881. {
  1882. public:
  1883.     TBButton(PTWindowsObject AParent, int AnId, LPSTR AText,
  1884.             int X, int Y, int W, int H, BOOL IsDefault,
  1885.         PTModule AModule = NULL);
  1886.     TBButton(PTWindowsObject AParent, int ResourceId,
  1887.         PTModule AModule = NULL);
  1888.     static PTStreamable build();
  1889.  
  1890. protected:
  1891.     virtual LPSTR GetClassName()
  1892.         {return "BORBTN";}
  1893.     TBButton(StreamableInit) : TButton(streamableInit) {};
  1894.  
  1895. private:
  1896.     virtual const Pchar streamableName() const
  1897.         { return "TBButton"; }
  1898. };
  1899.  
  1900. inline Ripstream operator >> ( Ripstream is, RTBButton cl )
  1901.     { return is >> (RTStreamable)cl; }
  1902. inline Ripstream operator >> ( Ripstream is, RPTBButton cl )
  1903.     { return is >> (RPvoid)cl; }
  1904.  
  1905. inline Ropstream operator << ( Ropstream os, RTBButton cl )
  1906.     { return os << (RTStreamable)cl; }
  1907. inline Ropstream operator << ( Ropstream os, PTBButton cl )
  1908.     { return os << (PTStreamable)cl; }
  1909.  
  1910. _CLASSDEF(TGroupBox)
  1911.  
  1912. /* --------------------------------------------------------
  1913.   TGroupBox object
  1914.   -------------------------------------------------------- */
  1915. class _EXPORT TGroupBox : public TControl
  1916. {
  1917. public:
  1918.     BOOL NotifyParent;
  1919.  
  1920.     TGroupBox(PTWindowsObject AParent, int AnId, LPSTR AText, int X,
  1921.               int Y, int W, int H, PTModule AModule = NULL);
  1922.     TGroupBox(PTWindowsObject AParent, int ResourceId,
  1923.               PTModule AModule = NULL);
  1924.     virtual void SelectionChanged(int ControlId);
  1925.  
  1926.     static PTStreamable build();
  1927.  
  1928. protected:
  1929.     virtual LPSTR GetClassName()
  1930.         { return "BUTTON"; }
  1931.  
  1932.     TGroupBox(StreamableInit) : TControl(streamableInit) {};
  1933.     virtual void write (Ropstream os);
  1934.     virtual Pvoid read (Ripstream is);
  1935.  
  1936. private:
  1937.     virtual const Pchar streamableName() const
  1938.         { return "TGroupBox"; }
  1939. };
  1940.  
  1941. inline Ripstream operator >> ( Ripstream is, RTGroupBox cl )
  1942.     { return is >> (RTStreamable )cl; }
  1943. inline Ripstream operator >> ( Ripstream is, RPTGroupBox cl )
  1944.     { return is >> (RPvoid)cl; }
  1945.  
  1946. inline Ropstream operator << ( Ropstream os, RTGroupBox cl )
  1947.     { return os << (RTStreamable )cl; }
  1948. inline Ropstream operator << ( Ropstream os, PTGroupBox cl )
  1949.     { return os << (PTStreamable )cl; }
  1950.  
  1951. _CLASSDEF(TBGroupBox)
  1952.  
  1953. /* --------------------------------------------------------
  1954.   TBGroupBox object
  1955.   -------------------------------------------------------- */
  1956. class _EXPORT TBGroupBox : public TGroupBox
  1957. {
  1958. public:
  1959.     TBGroupBox(PTWindowsObject AParent, int AnId, LPSTR AText, int X,
  1960.               int Y, int W, int H, PTModule AModule = NULL);
  1961.     TBGroupBox(PTWindowsObject AParent, int ResourceId,
  1962.             PTModule AModule = NULL);
  1963.  
  1964.     static PTStreamable build();
  1965.  
  1966. protected:
  1967.     virtual LPSTR GetClassName()
  1968.         {return "BORSHADE";}
  1969.     TBGroupBox(StreamableInit) : TGroupBox(streamableInit) {};
  1970.  
  1971. private:
  1972.     virtual const Pchar streamableName() const
  1973.         { return "TBGroupBox"; }
  1974. };
  1975.  
  1976. inline Ripstream operator >> ( Ripstream is, RTBGroupBox cl )
  1977.     { return is >> (RTStreamable )cl; }
  1978. inline Ripstream operator >> ( Ripstream is, RPTBGroupBox cl )
  1979.     { return is >> (RPvoid)cl; }
  1980.  
  1981. inline Ropstream operator << ( Ropstream os, RTBGroupBox cl )
  1982.     { return os << (RTStreamable )cl; }
  1983. inline Ropstream operator << ( Ropstream os, PTBGroupBox cl )
  1984.     { return os << (PTStreamable )cl; }
  1985.  
  1986. _CLASSDEF(TListBox)
  1987. _CLASSDEF(TListBoxData)
  1988.  
  1989. /* --------------------------------------------------------
  1990.   TListBox object
  1991.   -------------------------------------------------------- */
  1992.  
  1993. class _EXPORT TListBox : public TControl
  1994. {
  1995. public:
  1996.     TListBox(PTWindowsObject AParent, int AnId, int X, int Y,
  1997.              int W, int H, PTModule AModule = NULL);
  1998.     TListBox(PTWindowsObject AParent, int ResourceId, PTModule AModule = NULL)
  1999.              : TControl(AParent, ResourceId, AModule){};
  2000.  
  2001.     int AddString(LPSTR AString);
  2002.     int InsertString(LPSTR AString, int Index);
  2003.     int DeleteString(int Index);
  2004.     void ClearList();
  2005.     virtual WORD Transfer(Pvoid DataPtr, WORD TransferFlag);
  2006.     int GetCount();
  2007.     int FindString(LPSTR AString, int SearchIndex);
  2008.     int FindExactString(LPSTR AString, int SearchIndex);
  2009.     int GetString(LPSTR AString, int Index);
  2010.     int GetStringLen(int Index);
  2011.  
  2012.     // next four functions only for single-selection
  2013.     // list boxes (and combo boxes).
  2014.     int GetSelString(LPSTR AString, int MaxChars);
  2015.     int SetSelString(LPSTR AString, int SearchIndex);
  2016.     int GetSelIndex();
  2017.     int SetSelIndex(int Index);
  2018.  
  2019.     int GetSelCount();
  2020.  
  2021.     // next four functions only for multiple-selection list boxes.
  2022.     int GetSelStrings(LPSTR *Strings, int MaxCount, int MaxChars);
  2023.     int SetSelStrings(LPSTR *Prefixes, int NumSelections,
  2024.                       BOOL ShouldSet);
  2025.     int GetSelIndexes(Pint Indexes, int MaxCount);
  2026.     int SetSelIndexes(Pint Indexes, int NumSelections,
  2027.                       BOOL ShouldSet);
  2028.  
  2029.     static PTStreamable build();
  2030.  
  2031. protected:
  2032.     virtual LPSTR GetClassName()
  2033.         { return "LISTBOX"; }
  2034.     virtual WORD GetMsgID(WORD AMsg);
  2035.  
  2036.     TListBox(StreamableInit) : TControl(streamableInit) {};
  2037.  
  2038. private:
  2039.     virtual const Pchar streamableName() const
  2040.         { return "TListBox"; }
  2041. };
  2042.  
  2043. inline Ripstream operator >> ( Ripstream is, RTListBox cl )
  2044.     { return is >> (RTStreamable )cl; }
  2045. inline Ripstream operator >> ( Ripstream is, RPTListBox cl )
  2046.     { return is >> (RPvoid)cl; }
  2047.  
  2048. inline Ropstream operator << ( Ropstream os, RTListBox cl )
  2049.     { return os << (RTStreamable )cl; }
  2050. inline Ropstream operator << ( Ropstream os, PTListBox cl )
  2051.     { return os << (PTStreamable )cl; }
  2052.  
  2053. enum msgname {MN_ADDSTRING,    MN_INSERTSTRING, MN_DELETESTRING,
  2054.               MN_RESETCONTENT, MN_GETCOUNT,     MN_GETTEXT,
  2055.               MN_GETTEXTLEN,   MN_SELECTSTRING, MN_SETCURSEL,
  2056.               MN_GETCURSEL,    MN_FINDSTRING };
  2057.  
  2058. class _EXPORT TListBoxData
  2059. {
  2060. public:
  2061.     PArray Strings;
  2062.     PArray SelStrings;
  2063.     int SelCount;
  2064.  
  2065.     TListBoxData();
  2066.     ~TListBoxData();
  2067.     void AddString(Pchar AString, BOOL IsSelected = FALSE);
  2068.     void SelectString(LPSTR AString);
  2069.     void ResetSelections();
  2070.     int GetSelStringLength(int Index = 0);
  2071.     void GetSelString(LPSTR Buffer, int BufferSize, int Index = 0);
  2072. };
  2073.  
  2074. // TScrollBar transfer structure
  2075. struct TScrollBarData {
  2076.   int LowValue;
  2077.   int HighValue;
  2078.   int Position;
  2079. };
  2080.  
  2081. _CLASSDEF(TScrollBar)
  2082.  
  2083. /* --------------------------------------------------------
  2084.   TScrollBar object
  2085.   -------------------------------------------------------- */
  2086.  
  2087. class _EXPORT TScrollBar : public TControl
  2088. {
  2089. public:
  2090.     int LineMagnitude, PageMagnitude;
  2091.  
  2092.     TScrollBar(PTWindowsObject AParent, int AnId, int X, int Y, int W,
  2093.                int H, BOOL IsHScrollBar, PTModule AModule = NULL);
  2094.     TScrollBar(PTWindowsObject AParent, int ResourceId,
  2095.                PTModule AModule = NULL);
  2096.  
  2097.     void GetRange(Rint LoVal, Rint HiVal);
  2098.     int GetPosition();
  2099.     void SetRange(int LoVal, int HiVal);
  2100.     void SetPosition(int ThumbPos);
  2101.     int DeltaPos(int Delta);
  2102.     virtual WORD Transfer(Pvoid DataPtr, WORD TransferFlag);
  2103.  
  2104.     static PTStreamable build();
  2105.  
  2106. protected:
  2107.     virtual LPSTR GetClassName()
  2108.         { return "SCROLLBAR"; }
  2109.     virtual void SetupWindow();
  2110.  
  2111.     virtual void SBLineUp(RTMessage Msg) = [NF_FIRST + SB_LINEUP];
  2112.     virtual void SBLineDown(RTMessage Msg) = [NF_FIRST + SB_LINEDOWN];
  2113.     virtual void SBPageUp(RTMessage Msg) = [NF_FIRST + SB_PAGEUP];
  2114.     virtual void SBPageDown(RTMessage Msg) = [NF_FIRST + SB_PAGEDOWN];
  2115.     virtual void SBThumbPosition(RTMessage Msg) =
  2116.                                       [NF_FIRST + SB_THUMBPOSITION];
  2117.     virtual void SBThumbTrack(RTMessage Msg) = [NF_FIRST + SB_THUMBTRACK];
  2118.     virtual void SBTop(RTMessage Msg) = [NF_FIRST + SB_TOP];
  2119.     virtual void SBBottom(RTMessage Msg) = [NF_FIRST + SB_BOTTOM];
  2120.  
  2121.     TScrollBar(StreamableInit) : TControl(streamableInit) {};
  2122.     virtual void write (Ropstream os);
  2123.     virtual Pvoid read (Ripstream is);
  2124.  
  2125. private:
  2126.     virtual const Pchar streamableName() const
  2127.         { return "TScrollBar"; }
  2128. };
  2129.  
  2130. inline Ripstream operator >> ( Ripstream is, RTScrollBar cl )
  2131.     { return is >> (RTStreamable )cl; }
  2132. inline Ripstream operator >> ( Ripstream is, RPTScrollBar cl )
  2133.     { return is >> (RPvoid)cl; }
  2134.  
  2135. inline Ropstream operator << ( Ropstream os, RTScrollBar cl )
  2136.     { return os << (RTStreamable )cl; }
  2137. inline Ropstream operator << ( Ropstream os, PTScrollBar cl )
  2138.     { return os << (PTStreamable )cl; }
  2139.  
  2140.   /* TStatic */
  2141.  
  2142. _CLASSDEF(TStatic)
  2143.  
  2144. class _EXPORT TStatic : public TControl
  2145. {
  2146. public:
  2147.     WORD TextLen;
  2148.  
  2149.     TStatic(PTWindowsObject AParent, int AnId, LPSTR ATitle, int X,
  2150.             int Y, int W, int H, WORD ATextLen, PTModule AModule = NULL);
  2151.     TStatic(PTWindowsObject AParent, int ResourceId, WORD ATextLen,
  2152.             PTModule AModule = NULL);
  2153.  
  2154.     /* Returns the length of the control's text. */
  2155.     int GetTextLen()
  2156.         { return GetWindowTextLength(HWindow); }
  2157.  
  2158.     /* Fills the passed string with the text of the associated text
  2159.        control.  Returns the number of characters copied. */
  2160.     int GetText(LPSTR ATextString, int MaxChars)
  2161.         { return GetWindowText(HWindow, ATextString, MaxChars); }
  2162.  
  2163.     /* Sets the contents of the associated static text control to
  2164.        the passed string. */
  2165.     void SetText(LPSTR ATextString)
  2166.         { SetWindowText(HWindow, ATextString); }
  2167.  
  2168.     /* Clears the text of the associated static text control. */
  2169.     void Clear()
  2170.         { SetText(""); }
  2171.  
  2172.     virtual WORD Transfer(Pvoid DataPtr, WORD TransferFlag);
  2173.  
  2174.     virtual Pchar nameOf() const
  2175.         { return "TStatic"; }
  2176.  
  2177.     static PTStreamable build();
  2178.  
  2179. protected:
  2180.     virtual LPSTR GetClassName()
  2181.         { return "STATIC"; }
  2182.  
  2183.     TStatic(StreamableInit) : TControl(streamableInit) {};
  2184.     virtual void write (Ropstream os);
  2185.     virtual Pvoid read (Ripstream is);
  2186. private:
  2187.     virtual const Pchar streamableName() const
  2188.         { return "TStatic"; }
  2189. };
  2190.  
  2191. inline Ripstream operator >> ( Ripstream is, RTStatic cl )
  2192.     { return is >> (RTStreamable)cl; }
  2193. inline Ripstream operator >> ( Ripstream is, RPTStatic cl )
  2194.     { return is >> (RPvoid)cl; }
  2195.  
  2196. inline Ropstream operator << ( Ropstream os, RTStatic cl )
  2197.     { return os << (RTStreamable)cl; }
  2198. inline Ropstream operator << ( Ropstream os, PTStatic cl )
  2199.     { return os << (PTStreamable)cl; }
  2200.  
  2201. _CLASSDEF(TComboBox)
  2202. _CLASSDEF(TComboBoxData)
  2203.  
  2204. /* --------------------------------------------------------
  2205.   TComboBox object
  2206.   -------------------------------------------------------- */
  2207.  
  2208. class _EXPORT TComboBox : public TListBox
  2209. {
  2210. public:
  2211.     WORD TextLen;
  2212.  
  2213.     TComboBox(PTWindowsObject AParent, int AnId, int X, int Y, int W,
  2214.               int H, DWORD AStyle, WORD ATextLen, PTModule AModule = NULL);
  2215.     TComboBox(PTWindowsObject AParent, int ResourceId, WORD ATextLen,
  2216.               PTModule AModule = NULL);
  2217.  
  2218.     /* Returns the length of the associated edit control's text. */
  2219.     int GetTextLen()
  2220.         { return GetWindowTextLength(HWindow); }
  2221.  
  2222.     /* Fills the supplied string with the text of the associated
  2223.        edit control. Returns the number of characters copied. */
  2224.     int GetText(LPSTR AString, int MaxChars)
  2225.         { return GetWindowText(HWindow, AString, MaxChars); }
  2226.  
  2227.     void SetText(LPSTR AString);
  2228.  
  2229.     /* Selects characters in the edit control of the combo box
  2230.        which are between StartPos and EndPos. Returns CB_ERR if
  2231.        the combo box does not have an edit control. */
  2232.     int SetEditSel(int StartPos, int EndPos)
  2233.         { return (int)SendMessage(HWindow, CB_SETEDITSEL,
  2234.                       0, MAKELONG(StartPos, EndPos)); }
  2235.  
  2236.     int GetEditSel(Rint StartPos, Rint EndPos);
  2237.  
  2238.     /* Clears the text of the associated edit control. */
  2239.     void Clear()
  2240.         { SetText(""); }
  2241.  
  2242.     void ShowList();
  2243.     void HideList();
  2244.     virtual WORD Transfer(Pvoid DataPtr, WORD TransferFlag);
  2245.     virtual Pchar nameOf() const
  2246.         { return "TComboBox"; }
  2247.  
  2248.     static PTStreamable build();
  2249.  
  2250. protected:
  2251.     virtual LPSTR GetClassName()
  2252.         {return "COMBOBOX";}
  2253.     virtual WORD GetMsgID(WORD AnId);
  2254.     virtual void SetupWindow();
  2255.  
  2256.     TComboBox(StreamableInit) : TListBox(streamableInit) {};
  2257.     virtual void write (Ropstream os);
  2258.     virtual Pvoid read (Ripstream is);
  2259.  
  2260. private:
  2261.     virtual const Pchar streamableName() const
  2262.         { return "TComboBox"; }
  2263. };
  2264.  
  2265. inline Ripstream operator >> ( Ripstream is, RTComboBox cl )
  2266.     { return is >> (RTStreamable )cl; }
  2267. inline Ripstream operator >> ( Ripstream is, RPTComboBox cl )
  2268.     { return is >> (RPvoid)cl; }
  2269.  
  2270. inline Ropstream operator << ( Ropstream os, RTComboBox cl )
  2271.     { return os << (RTStreamable )cl; }
  2272. inline Ropstream operator << ( Ropstream os, PTComboBox cl )
  2273.     { return os << (PTStreamable )cl; }
  2274.  
  2275. class _EXPORT TComboBoxData
  2276. {
  2277. public:
  2278.     PArray Strings;
  2279.     Pchar Selection;
  2280.  
  2281.     TComboBoxData();
  2282.     ~TComboBoxData();
  2283.     void AddString(Pchar AString, BOOL IsSelected = FALSE);
  2284. };
  2285.  
  2286. /* --------------------------------------------------------
  2287.   TCheckBox object
  2288.   -------------------------------------------------------- */
  2289.  
  2290. _CLASSDEF(TCheckBox)
  2291.  
  2292. class _EXPORT TCheckBox : public TButton
  2293. {
  2294. public:
  2295.     PTGroupBox Group;
  2296.  
  2297.     TCheckBox(PTWindowsObject AParent,int AnId, LPSTR ATitle, int X,
  2298.               int Y ,int W, int H, PTGroupBox AGroup,
  2299.           PTModule AModule = NULL);
  2300.     TCheckBox(PTWindowsObject AParent, int ResourceId,
  2301.               PTGroupBox AGroup, PTModule AModule = NULL);
  2302.     void Check();
  2303.     void Uncheck();
  2304.     void Toggle();
  2305.     WORD GetCheck();
  2306.     void SetCheck(WORD CheckFlag);
  2307.     virtual WORD Transfer(Pvoid DataPtr, WORD TransferFlag);
  2308.  
  2309.     static PTStreamable build();
  2310.  
  2311. protected:
  2312.     virtual void BNClicked(RTMessage Msg) = [NF_FIRST + BN_CLICKED];
  2313.  
  2314.     /* Override TButton's processing so drawable check boxes and radio
  2315.        buttons work properly. */
  2316.     virtual void WMGetDlgCode(RTMessage Msg) =
  2317.                          [WM_FIRST + WM_GETDLGCODE]
  2318.         { DefWndProc(Msg); }
  2319.  
  2320.     TCheckBox(StreamableInit) : TButton(streamableInit) {};
  2321.     virtual void write (Ropstream os);
  2322.     virtual Pvoid read (Ripstream is);
  2323.  
  2324. private:
  2325.     virtual const Pchar streamableName() const
  2326.         { return "TCheckBox"; }
  2327. };
  2328.  
  2329. inline Ripstream operator >> ( Ripstream is, RTCheckBox cl )
  2330.     { return is >> (RTStreamable )cl; }
  2331. inline Ripstream operator >> ( Ripstream is, RPTCheckBox cl )
  2332.     { return is >> (RPvoid)cl; }
  2333.  
  2334. inline Ropstream operator << ( Ropstream os, RTCheckBox cl )
  2335.     { return os << (RTStreamable )cl; }
  2336. inline Ropstream operator << ( Ropstream os, PTCheckBox cl )
  2337.     { return os << (PTStreamable )cl; }
  2338.  
  2339. _CLASSDEF(TBCheckBox)
  2340.  
  2341. /* --------------------------------------------------------
  2342.   TBCheckBox object
  2343.   -------------------------------------------------------- */
  2344.  
  2345. class _EXPORT TBCheckBox : public TCheckBox
  2346. {
  2347. public:
  2348.     TBCheckBox(PTWindowsObject AParent,int AnId, LPSTR ATitle, int X,
  2349.         int Y ,int W, int H, PTGroupBox AGroup,
  2350.         PTModule AModule = NULL);
  2351.     TBCheckBox(PTWindowsObject AParent, int ResourceId,
  2352.             PTGroupBox AGroup, PTModule AModule = NULL);
  2353.     static PTStreamable build();
  2354.  
  2355. protected:
  2356.     virtual LPSTR GetClassName()
  2357.         {return "BORCHECK";}
  2358.     TBCheckBox(StreamableInit) : TCheckBox(streamableInit) {};
  2359.  
  2360. private:
  2361.     virtual const Pchar streamableName() const
  2362.         { return "TBCheckBox"; }
  2363. };
  2364.  
  2365. inline Ripstream operator >> ( Ripstream is, RTBCheckBox cl )
  2366.     { return is >> (RTStreamable)cl; }
  2367. inline Ripstream operator >> ( Ripstream is, RPTBCheckBox cl )
  2368.     { return is >> (RPvoid)cl; }
  2369.  
  2370. inline Ropstream operator << ( Ropstream os, RTBCheckBox cl )
  2371.     { return os << (RTStreamable)cl; }
  2372. inline Ropstream operator << ( Ropstream os, PTBCheckBox cl )
  2373.     { return os << (PTStreamable)cl; }
  2374.  
  2375. _CLASSDEF(TRadioButton)
  2376.  
  2377. /* --------------------------------------------------------
  2378.   TRadioButton object
  2379.   -------------------------------------------------------- */
  2380. class _EXPORT TRadioButton : public TCheckBox
  2381. {
  2382. public:
  2383.     TRadioButton(PTWindowsObject AParent, int AnId, LPSTR ATitle,
  2384.                int X, int Y, int W, int H, PTGroupBox AGroup,
  2385.                PTModule AModule = NULL);
  2386.  
  2387.     TRadioButton(PTWindowsObject AParent, int ResourceId, PTGroupBox AGroup,
  2388.                PTModule AModule = NULL)
  2389.               : TCheckBox(AParent, ResourceId, AGroup, AModule){};
  2390.  
  2391.     static PTStreamable build();
  2392.  
  2393. protected:
  2394.     virtual void BNClicked(RTMessage Msg) = [NF_FIRST + BN_CLICKED];
  2395.  
  2396.     TRadioButton(StreamableInit) : TCheckBox(streamableInit) {};
  2397.  
  2398. private:
  2399.     virtual const Pchar streamableName() const
  2400.         { return "TRadioButton"; }
  2401. };
  2402.  
  2403. inline Ripstream operator >> ( Ripstream is, RTRadioButton cl )
  2404.     { return is >> (RTStreamable)cl; }
  2405. inline Ripstream operator >> ( Ripstream is, RPTRadioButton cl )
  2406.     { return is >> (RPvoid)cl; }
  2407.  
  2408. inline Ropstream operator << ( Ropstream os, RTRadioButton cl )
  2409.     { return os << (RTStreamable)cl; }
  2410. inline Ropstream operator << ( Ropstream os, PTRadioButton cl )
  2411.     { return os << (PTStreamable)cl; }
  2412.  
  2413. _CLASSDEF(TBRadioButton)
  2414.  
  2415. /* --------------------------------------------------------
  2416.   TBRadioButton object
  2417.   -------------------------------------------------------- */
  2418.  
  2419. class _EXPORT TBRadioButton : public TRadioButton
  2420. {
  2421. public:
  2422.   TBRadioButton(PTWindowsObject AParent, int AnId, LPSTR ATitle,
  2423.                  int X, int Y, int W, int H, PTGroupBox AGroup,
  2424.          PTModule AModule = NULL);
  2425.   TBRadioButton(PTWindowsObject AParent, int ResourceId, PTGroupBox AGroup,
  2426.          PTModule AModule = NULL)
  2427.               : TRadioButton(AParent, ResourceId, AGroup, AModule){};
  2428.   static PTStreamable build();
  2429.  
  2430. protected:
  2431.   virtual LPSTR GetClassName()
  2432.       {return "BORRADIO";}
  2433.   TBRadioButton(StreamableInit) : TRadioButton(streamableInit) {};
  2434.  
  2435. private:
  2436.     virtual const Pchar streamableName() const
  2437.         { return "TBRadioButton"; }
  2438. };
  2439.  
  2440. inline Ripstream operator >> ( Ripstream is, RTBRadioButton cl )
  2441.     { return is >> (RTStreamable)cl; }
  2442. inline Ripstream operator >> ( Ripstream is, RPTBRadioButton cl )
  2443.     { return is >> (RPvoid)cl; }
  2444.  
  2445. inline Ropstream operator << ( Ropstream os, RTBRadioButton cl )
  2446.     { return os << (RTStreamable)cl; }
  2447. inline Ropstream operator << ( Ropstream os, PTBRadioButton cl )
  2448.     { return os << (PTStreamable)cl; }
  2449.  
  2450. _CLASSDEF(TBStatic)
  2451.  
  2452. /* TBStatic */
  2453.  
  2454. class _EXPORT TBStatic : public TStatic
  2455. {
  2456. public:
  2457.     TBStatic(PTWindowsObject AParent, int AnId, LPSTR ATitle, int X,
  2458.             int Y, int W, int H, WORD ATextLen, PTModule AModule = NULL);
  2459.     TBStatic(PTWindowsObject AParent, int ResourceId, WORD ATextLen,
  2460.           PTModule AModule = NULL);
  2461.     virtual Pchar nameOf() const
  2462.         { return "TBStatic"; }
  2463.  
  2464.     static PTStreamable build();
  2465.  
  2466. protected:
  2467.     virtual LPSTR GetClassName()
  2468.         {return "BORSTATIC";}
  2469.     TBStatic(StreamableInit) : TStatic(streamableInit) {};
  2470.  
  2471. private:
  2472.     virtual const Pchar streamableName() const
  2473.         { return "TBStatic"; }
  2474. };
  2475.  
  2476. inline Ripstream operator >> ( Ripstream is, RTBStatic cl )
  2477.     { return is >> (RTStreamable)cl; }
  2478. inline Ripstream operator >> ( Ripstream is, RPTBStatic cl )
  2479.     { return is >> (RPvoid)cl; }
  2480.  
  2481. inline Ropstream operator << ( Ropstream os, RTBStatic cl )
  2482.     { return os << (RTStreamable)cl; }
  2483. inline Ropstream operator << ( Ropstream os, PTBStatic cl )
  2484.     { return os << (PTStreamable)cl; }
  2485.  
  2486. _CLASSDEF(TEdit)
  2487.  
  2488.   /* TEdit */
  2489. class _EXPORT TEdit : public TStatic
  2490. {
  2491. public:
  2492.     TEdit(PTWindowsObject AParent, int AnId, LPSTR AText, int X,
  2493.           int Y, int W, int H, WORD ATextLen, BOOL Multiline,
  2494.           PTModule AModule = NULL);
  2495.     TEdit(PTWindowsObject AParent, int ResourceId, WORD ATextLen,
  2496.           PTModule AModule = NULL);
  2497.  
  2498.     void Undo();
  2499.     BOOL CanUndo();
  2500.     void Paste();
  2501.     void Copy();
  2502.     void Cut();
  2503.     int GetNumLines();
  2504.     int GetLineLength(int LineNumber);
  2505.     BOOL GetLine(LPSTR ATextString, int StrSize, int LineNumber);
  2506.     void GetSubText(LPSTR ATextString, int StartPos, int EndPos);
  2507.     BOOL DeleteSubText(int StartPos, int EndPos);
  2508.     BOOL DeleteLine(int LineNumber);
  2509.     void GetSelection(Rint StartPos, Rint EndPos);
  2510.     BOOL DeleteSelection();
  2511.     BOOL IsModified();
  2512.     void ClearModify();
  2513.     int GetLineFromPos(int CharPos);
  2514.     int GetLineIndex(int LineNumber);
  2515.     void Scroll(int HorizontalUnit, int VerticalUnit);
  2516.     BOOL SetSelection(int StartPos, int EndPos);
  2517.     void Insert(LPSTR ATextString);
  2518.     int Search(int StartPos, LPSTR AText, BOOL CaseSensitive);
  2519.  
  2520.     static PTStreamable build();
  2521.  
  2522. protected:
  2523.     virtual LPSTR GetClassName()
  2524.     { return "EDIT"; }
  2525.     virtual void SetupWindow();
  2526.     virtual void CMEditCut(RTMessage Msg) = [CM_FIRST + CM_EDITCUT];
  2527.     virtual void CMEditCopy(RTMessage Msg) = [CM_FIRST + CM_EDITCOPY];
  2528.     virtual void CMEditPaste(RTMessage Msg) = [CM_FIRST + CM_EDITPASTE];
  2529.     virtual void CMEditDelete(RTMessage Msg) =
  2530.                                         [CM_FIRST + CM_EDITDELETE];
  2531.     virtual void CMEditClear(RTMessage Msg) = [CM_FIRST + CM_EDITCLEAR];
  2532.     virtual void CMEditUndo(RTMessage Msg) = [CM_FIRST + CM_EDITUNDO];
  2533.     virtual void ENErrSpace(RTMessage Msg) = [NF_FIRST + EN_ERRSPACE];
  2534.  
  2535.     TEdit(StreamableInit) : TStatic(streamableInit) {};
  2536.  
  2537. private:
  2538.     virtual const Pchar streamableName() const
  2539.         { return "TEdit"; }
  2540. };
  2541.  
  2542. inline Ripstream operator >> ( Ripstream is, RTEdit cl )
  2543.     { return is >> (RTStreamable )cl; }
  2544. inline Ripstream operator >> ( Ripstream is, RPTEdit cl )
  2545.     { return is >> (RPvoid)cl; }
  2546.  
  2547. inline Ropstream operator << ( Ropstream os, RTEdit cl )
  2548.     { return os << (RTStreamable )cl; }
  2549. inline Ropstream operator << ( Ropstream os, PTEdit cl )
  2550.     { return os << (PTStreamable )cl; }
  2551.  
  2552. struct _CLASSTYPE TSearchStruct { // _CLASSTYPE needed for BC++ 2.0
  2553.   char SearchText[81];
  2554.   BOOL CaseSensitive;
  2555.   char ReplaceText[81];
  2556.   BOOL ReplaceAll;
  2557.   BOOL PromptOnReplace;
  2558. };
  2559.  
  2560. _CLASSDEF(TEditWindow)
  2561. _CLASSDEF(TSearchDialog)
  2562.  
  2563. /* TEditWindow declaration */
  2564.  
  2565. class _EXPORT TEditWindow : public TWindow
  2566. {
  2567. public:
  2568.     PTEdit Editor;
  2569.     TSearchStruct SearchStruct;
  2570.     BOOL IsReplaceOp; // True if the search is a search and replace.
  2571.  
  2572.     TEditWindow(PTWindowsObject AParent, LPSTR ATitle,
  2573.         PTModule AModule = NULL);
  2574.     void DoSearch();
  2575.  
  2576.     static PTStreamable build();
  2577.  
  2578. protected:
  2579.     virtual void WMSize(RTMessage Msg) = [WM_FIRST + WM_SIZE];
  2580.     virtual void WMSetFocus(RTMessage Msg) = [WM_FIRST + WM_SETFOCUS];
  2581.     virtual void CMEditFind(RTMessage Msg) = [CM_FIRST + CM_EDITFIND];
  2582.     virtual void CMEditFindNext(RTMessage Msg) =
  2583.                                [CM_FIRST + CM_EDITFINDNEXT];
  2584.     virtual void CMEditReplace(RTMessage Msg) =
  2585.                                [CM_FIRST + CM_EDITREPLACE];
  2586.  
  2587.     TEditWindow(StreamableInit) : TWindow(streamableInit) {};
  2588.     virtual void write (Ropstream os);
  2589.     virtual Pvoid read (Ripstream is);
  2590.  
  2591. private:
  2592.     virtual const Pchar streamableName() const
  2593.         { return "TEditWindow"; }
  2594. };
  2595.  
  2596. inline Ripstream operator >> ( Ripstream is, RTEditWindow cl )
  2597.     { return is >> (RTStreamable )cl; }
  2598. inline Ripstream operator >> ( Ripstream is, RPTEditWindow cl )
  2599.     { return is >> (RPvoid)cl; }
  2600.  
  2601. inline Ropstream operator << ( Ropstream os, RTEditWindow cl )
  2602.     { return os << (RTStreamable )cl; }
  2603. inline Ropstream operator << ( Ropstream os, PTEditWindow cl )
  2604.     { return os << (PTStreamable )cl; }
  2605.  
  2606. class _EXPORT TSearchDialog : public TDialog
  2607. {
  2608. public:
  2609.   TSearchDialog(PTWindowsObject AParent, int ResourceId,
  2610.                 TSearchStruct _FAR &SearchStruct,
  2611.                 PTModule AModule = NULL);
  2612. };
  2613.  
  2614.  /* TFileWindow */
  2615.  
  2616. _CLASSDEF(TFileWindow)
  2617.  
  2618. class _EXPORT TFileWindow : public TEditWindow
  2619. {
  2620. public:
  2621.     LPSTR FileName;
  2622.     BOOL IsNewFile;
  2623.  
  2624.     TFileWindow(PTWindowsObject AParent, LPSTR ATitle, LPSTR AFileName,
  2625.                 PTModule AModule = NULL);
  2626.     virtual ~TFileWindow();
  2627.  
  2628.     virtual BOOL CanClear();
  2629.     virtual BOOL CanClose();
  2630.     void NewFile();
  2631.     void Open();
  2632.     BOOL Read();
  2633.     void ReplaceWith(LPSTR AFileName);
  2634.     BOOL Save();
  2635.     BOOL SaveAs();
  2636.     void SetFileName(LPSTR AFileName);
  2637.     BOOL Write();
  2638.  
  2639.     static PTStreamable build();
  2640.  
  2641. protected:
  2642.     virtual void SetupWindow();
  2643.     virtual void CMFileNew(RTMessage Msg) = [CM_FIRST + CM_FILENEW];
  2644.     virtual void CMFileOpen(RTMessage Msg) = [CM_FIRST + CM_FILEOPEN];
  2645.     virtual void CMFileSave(RTMessage Msg) = [CM_FIRST + CM_FILESAVE];
  2646.     virtual void CMFileSaveAs(RTMessage Msg) =
  2647.                                          [CM_FIRST + CM_FILESAVEAS];
  2648.  
  2649.     TFileWindow(StreamableInit) : TEditWindow(streamableInit) {};
  2650.     virtual void write (Ropstream os);
  2651.     virtual Pvoid read (Ripstream is);
  2652.  
  2653. private:
  2654.     virtual const Pchar streamableName() const
  2655.         { return "TFileWindow"; }
  2656. };
  2657.  
  2658. inline Ripstream operator >> ( Ripstream is, RTFileWindow cl )
  2659.     { return is >> (RTStreamable)cl; }
  2660. inline Ripstream operator >> ( Ripstream is, RPTFileWindow cl )
  2661.     { return is >> (RPvoid)cl; }
  2662.  
  2663. inline Ropstream operator << ( Ropstream os, RTFileWindow cl )
  2664.     { return os << (RTStreamable)cl; }
  2665. inline Ropstream operator << ( Ropstream os, PTFileWindow cl )
  2666.     { return os << (PTStreamable)cl; }
  2667.  
  2668. // Application Class
  2669.  
  2670. _CLASSDEF(TApplication)
  2671.  
  2672. class _EXPORT TApplication : public TModule {
  2673. public:
  2674.  
  2675.     // WinMain arguments
  2676.     HINSTANCE         hPrevInstance;
  2677.     int            nCmdShow;
  2678.  
  2679.     PTWindowsObject MainWindow;
  2680.     HACCEL HAccTable;
  2681.     PTWindowsObject KBHandlerWnd;
  2682.  
  2683. #if defined(WIN31)
  2684.     // windows 3.1 interface
  2685.     TApplication(LPSTR AName, HINSTANCE AnInstance,
  2686.               HINSTANCE APrevInstance, LPSTR ACmdLine, int ACmdShow);
  2687. #endif
  2688. #if defined(WIN30)
  2689.     // windows 3.0 interface
  2690.     TApplication(LPSTR AName, HINSTANCE_30 AnInstance,
  2691.               HINSTANCE_30 APrevInstance, LPSTR ACmdLine, int ACmdShow);
  2692. #endif
  2693.  
  2694.     ~TApplication();
  2695.     virtual void Run();
  2696.     virtual BOOL CanClose();
  2697.     void SetKBHandler(PTWindowsObject AWindowsObject);
  2698.  
  2699.     // define pure virtual functions derived from Object class
  2700.     virtual classType        isA() const
  2701.          { return applicationClass; }
  2702.     virtual Pchar nameOf() const
  2703.          {return "TApplication";}
  2704. protected:
  2705.     virtual void InitApplication();  // "first"-instance initialization
  2706.     virtual void InitInstance();     // each-instance initialization
  2707.     virtual void InitMainWindow();   // init application main window
  2708.  
  2709.     virtual void MessageLoop();
  2710.     /* IdleAction may be redefined in derived classes to do some action when
  2711.        there are no messages pending. */
  2712.     virtual void IdleAction() {}
  2713.     virtual BOOL ProcessAppMsg(LPMSG PMessage);
  2714.     virtual BOOL ProcessDlgMsg(LPMSG PMessage);
  2715.     virtual BOOL ProcessAccels(LPMSG PMessage);
  2716.     virtual BOOL ProcessMDIAccels(LPMSG PMessage);
  2717.  
  2718. private:
  2719.  
  2720.     void __TApplication(LPSTR AName, HINSTANCE AnInstance,
  2721.                     HINSTANCE APrevInstance, LPSTR ACmdLine, int ACmdShow);
  2722.  
  2723. };    // end of Application class
  2724.  
  2725. /* Performs special handling for the message last retrieved.
  2726.    Translates keyboard input messages into control selections or
  2727.    command messages, when appropriate.  Dispatches message, if
  2728.    translated. */
  2729. inline BOOL TApplication::ProcessAppMsg(LPMSG PMessage)
  2730.        { if ( KBHandlerWnd )
  2731.            if ( KBHandlerWnd->IsFlagSet(WB_MDICHILD) )
  2732.              return ProcessMDIAccels(PMessage) ||
  2733.                     ProcessDlgMsg(PMessage) ||
  2734.                     ProcessAccels(PMessage);
  2735.            else
  2736.             return ProcessDlgMsg(PMessage) ||
  2737.                    ProcessMDIAccels(PMessage) ||
  2738.                    ProcessAccels(PMessage);
  2739.          else
  2740.            return ProcessMDIAccels(PMessage) ||
  2741.                   ProcessAccels(PMessage); }
  2742.  
  2743. /* Attempts to translate a message into a control selection if the
  2744.    currently active OWL window has requested "keyboard handling".
  2745.    (Some keyboard input messages are translated into control
  2746.    selection messages). Dispatches message, if translated. */
  2747. inline BOOL TApplication::ProcessDlgMsg(LPMSG PMessage)
  2748.     { if (KBHandlerWnd && KBHandlerWnd->HWindow)
  2749.            return IsDialogMessage(KBHandlerWnd->HWindow, PMessage);
  2750.          else
  2751.            return FALSE; }
  2752.  
  2753. /* Attempts to translate a message into a command message if the
  2754.    TApplication has loaded an accelerator table. (Keyboard input
  2755.    messages for which an entry exists in the accelerator table are
  2756.    translated into command messages.)  Dispatches message, if
  2757.    translated.  (Translation of MDI accelerator messages is performed
  2758.    in ProcessMDIAccels function.) */
  2759. inline BOOL TApplication::ProcessAccels(LPMSG PMessage)
  2760.        { return HAccTable &&
  2761.          TranslateAccelerator(
  2762.                  MainWindow->HWindow, HAccTable, PMessage); }
  2763.  
  2764. /* Attempts to translate a message into a system command message
  2765.    for MDI TApplications (whose main window is a TMDIFrame). (Some
  2766.    keyboard input messages are translated into system commands for
  2767.    MDI applications). Dispatches message, if translated. */
  2768. inline BOOL TApplication::ProcessMDIAccels(LPMSG PMessage)
  2769.        { return (PTWindowsObject)(MainWindow->GetClient()) &&
  2770.            TranslateMDISysAccel(
  2771.             ((PTWindowsObject)(MainWindow->GetClient()))->HWindow, PMessage); }
  2772.  
  2773. /* Activates and deactivates "keyboard handling" (translation of
  2774.    keyboard input into control selections) for the currently active
  2775.    TWindowsObject by setting the KBHandlerWnd to the parameter passed.
  2776.    This function is called internally by the OWL whenever a OWL window
  2777.    is activated.  If "keyboard handling" has been requested for the
  2778.    TWindowsObject, the parameter passed is non-NULL, else NULL is
  2779.    passed.  "Keyboard handling" is requested, by default, for all
  2780.    modeless dialogs and may be requested for a TWindow via a call to
  2781.    its EnableKBHandler function. */
  2782. inline void TApplication::SetKBHandler(PTWindowsObject AWindowsObject)
  2783.        { KBHandlerWnd = AWindowsObject; }
  2784.  
  2785. extern PTApplication _EXPFUNC GetApplicationObject();
  2786.  
  2787. const int DEFAULT_DICTIONARY_SIZE = 10;
  2788. const int DEFAULT_DICTIONARY_INCREMENT = 10;
  2789.  
  2790. class _CLASSTYPE TAppDictionaryEntry
  2791. {
  2792. public:
  2793.     HANDLE hTask;
  2794.     PTApplication pApplication;
  2795. };
  2796.  
  2797. class _CLASSTYPE TAppDictionary
  2798. {
  2799.     int NumEntries;
  2800.     TAppDictionaryEntry * Table;
  2801. public:
  2802.     TAppDictionary(int InitialCount = DEFAULT_DICTIONARY_SIZE);
  2803.     ~TAppDictionary();
  2804.  
  2805.     static TAppDictionaryEntry * AllocTable(int Count);
  2806.     static void FreeTable(TAppDictionaryEntry *pTable);
  2807.  
  2808.     TAppDictionaryEntry *GrowTable(int Increment =
  2809.                                    DEFAULT_DICTIONARY_INCREMENT);
  2810.     void Add(PTApplication pApplication);
  2811.     void Delete();
  2812.     PTApplication Lookup();
  2813. };
  2814.  
  2815. extern unsigned short far  _EXPFUNC OWLGetVersion();
  2816.  
  2817. const unsigned short OWLVersion = 0x0110; // Version 1.1
  2818.  
  2819. #endif  // __OWLHDR_H
  2820.  
  2821.